diff --git a/Sources/Dto/Classe/EcurieDTO.cs b/Sources/Dto/Classe/EcurieDTO.cs index c9b2f37..87552cb 100644 --- a/Sources/Dto/Classe/EcurieDTO.cs +++ b/Sources/Dto/Classe/EcurieDTO.cs @@ -9,5 +9,8 @@ namespace Dto.Classe public class EcurieDTO { public string Name { get; set; } + public List Members { get; set; } + public List WaitingsMembers { get; set; } + public PiloteDTO Owner { get; set; } } } diff --git a/Sources/Entity_Framework/BDD.db b/Sources/Entity_Framework/BDD.db index 2e4f481..30720dd 100644 Binary files a/Sources/Entity_Framework/BDD.db and b/Sources/Entity_Framework/BDD.db differ diff --git a/Sources/Entity_Framework/BDD.db-shm b/Sources/Entity_Framework/BDD.db-shm deleted file mode 100644 index fe9ac28..0000000 Binary files a/Sources/Entity_Framework/BDD.db-shm and /dev/null differ diff --git a/Sources/Entity_Framework/BDD.db-wal b/Sources/Entity_Framework/BDD.db-wal deleted file mode 100644 index e69de29..0000000 diff --git a/Sources/Entity_Framework/BDDContext.cs b/Sources/Entity_Framework/BDDContext.cs index 1b4c267..b6ecb50 100644 --- a/Sources/Entity_Framework/BDDContext.cs +++ b/Sources/Entity_Framework/BDDContext.cs @@ -155,7 +155,7 @@ namespace Entity_Framework { if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseSqlite($"Data Source=BDD.db"); + optionsBuilder.UseSqlite($"Data Source=..\\Entity_Framework\\BDD.db"); // optionsBuilder.UseSqlite($"Data Source=C:\\Users\\Jolys Enzo\\home\\BUT\\Projet\\Sae4.01\\Projet\\R-Dash_APP\\Entity_Framework\\BDD.db"); //optionsBuilder.UseSqlite($"Data Source=C:\\Users\\zinn1\\Source\\Repos\\Serveur-Api2\\Sources\\Entity_Framework\\BDD.db"); } diff --git a/Sources/Entity_Framework/Migrations/20230317102828_test.Designer.cs b/Sources/Entity_Framework/Migrations/20230322173709_test.Designer.cs similarity index 87% rename from Sources/Entity_Framework/Migrations/20230317102828_test.Designer.cs rename to Sources/Entity_Framework/Migrations/20230322173709_test.Designer.cs index aeb7329..3cd1c85 100644 --- a/Sources/Entity_Framework/Migrations/20230317102828_test.Designer.cs +++ b/Sources/Entity_Framework/Migrations/20230322173709_test.Designer.cs @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Entity_Framework.Migrations { [DbContext(typeof(BDDContext))] - [Migration("20230317102828_test")] + [Migration("20230322173709_test")] partial class test { /// @@ -100,9 +100,6 @@ namespace Entity_Framework.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("IdEcurie") - .HasColumnType("INTEGER"); - b.Property("Password") .IsRequired() .HasColumnType("TEXT"); @@ -116,8 +113,6 @@ namespace Entity_Framework.Migrations b.HasIndex("Email") .IsUnique(); - b.HasIndex("IdEcurie"); - b.HasIndex("Pseudo") .IsUnique(); @@ -182,6 +177,33 @@ namespace Entity_Framework.Migrations b.ToTable("Points"); }); + modelBuilder.Entity("Entity_Framework.Entity.Relations.Relation_Pilote_Ecurie", b => + { + b.Property("IdPilote") + .HasColumnType("INTEGER"); + + b.Property("IdEcurie") + .HasColumnType("INTEGER"); + + b.Property("EcurieId") + .HasColumnType("INTEGER"); + + b.Property("Grade") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PiloteId") + .HasColumnType("INTEGER"); + + b.HasKey("IdPilote", "IdEcurie"); + + b.HasIndex("EcurieId"); + + b.HasIndex("PiloteId"); + + b.ToTable("RelationEcuriePilote"); + }); + modelBuilder.Entity("Entity_Framework.Entity.Sessions", b => { b.Property("Id") @@ -259,15 +281,6 @@ namespace Entity_Framework.Migrations b.Navigation("Pilote"); }); - modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b => - { - b.HasOne("Entity_Framework.Entity.Ecuries", "Ecurie") - .WithMany("Pilotes") - .HasForeignKey("IdEcurie"); - - b.Navigation("Ecurie"); - }); - modelBuilder.Entity("Entity_Framework.Entity.Points", b => { b.HasOne("Entity_Framework.Entity.Tours", "Tours") @@ -279,6 +292,25 @@ namespace Entity_Framework.Migrations b.Navigation("Tours"); }); + modelBuilder.Entity("Entity_Framework.Entity.Relations.Relation_Pilote_Ecurie", b => + { + b.HasOne("Entity_Framework.Entity.Ecuries", "Ecurie") + .WithMany("PilotesRelation") + .HasForeignKey("EcurieId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity_Framework.Entity.Pilotes", "Pilote") + .WithMany("Ecurie") + .HasForeignKey("PiloteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ecurie"); + + b.Navigation("Pilote"); + }); + modelBuilder.Entity("Entity_Framework.Entity.Sessions", b => { b.HasOne("Entity_Framework.Entity.Circuits", "Circuit") @@ -316,11 +348,13 @@ namespace Entity_Framework.Migrations modelBuilder.Entity("Entity_Framework.Entity.Ecuries", b => { - b.Navigation("Pilotes"); + b.Navigation("PilotesRelation"); }); modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b => { + b.Navigation("Ecurie"); + b.Navigation("EcuriePropriétaire") .IsRequired(); diff --git a/Sources/Entity_Framework/Migrations/20230317102828_test.cs b/Sources/Entity_Framework/Migrations/20230322173709_test.cs similarity index 82% rename from Sources/Entity_Framework/Migrations/20230317102828_test.cs rename to Sources/Entity_Framework/Migrations/20230322173709_test.cs index 94ddb0e..f801a94 100644 --- a/Sources/Entity_Framework/Migrations/20230317102828_test.cs +++ b/Sources/Entity_Framework/Migrations/20230322173709_test.cs @@ -25,38 +25,38 @@ namespace Entity_Framework.Migrations }); migrationBuilder.CreateTable( - name: "Ecuries", + name: "Pilotes", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(type: "TEXT", nullable: false), - IdPiloteProprietaire = table.Column(type: "INTEGER", nullable: false) + Pseudo = table.Column(type: "TEXT", nullable: false), + Email = table.Column(type: "TEXT", nullable: false), + Password = table.Column(type: "TEXT", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Ecuries", x => x.Id); + table.PrimaryKey("PK_Pilotes", x => x.Id); }); migrationBuilder.CreateTable( - name: "Pilotes", + name: "Ecuries", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - Pseudo = table.Column(type: "TEXT", nullable: false), - Email = table.Column(type: "TEXT", nullable: false), - Password = table.Column(type: "TEXT", nullable: false), - IdEcurie = table.Column(type: "INTEGER", nullable: true) + Name = table.Column(type: "TEXT", nullable: false), + IdPiloteProprietaire = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Pilotes", x => x.Id); + table.PrimaryKey("PK_Ecuries", x => x.Id); table.ForeignKey( - name: "FK_Pilotes_Ecuries_IdEcurie", - column: x => x.IdEcurie, - principalTable: "Ecuries", - principalColumn: "Id"); + name: "FK_Ecuries_Pilotes_IdPiloteProprietaire", + column: x => x.IdPiloteProprietaire, + principalTable: "Pilotes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -108,6 +108,33 @@ namespace Entity_Framework.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "RelationEcuriePilote", + columns: table => new + { + IdPilote = table.Column(type: "INTEGER", nullable: false), + IdEcurie = table.Column(type: "INTEGER", nullable: false), + Grade = table.Column(type: "TEXT", nullable: false), + PiloteId = table.Column(type: "INTEGER", nullable: false), + EcurieId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RelationEcuriePilote", x => new { x.IdPilote, x.IdEcurie }); + table.ForeignKey( + name: "FK_RelationEcuriePilote_Ecuries_EcurieId", + column: x => x.EcurieId, + principalTable: "Ecuries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RelationEcuriePilote_Pilotes_PiloteId", + column: x => x.PiloteId, + principalTable: "Pilotes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "Tours", columns: table => new @@ -166,8 +193,8 @@ namespace Entity_Framework.Migrations migrationBuilder.InsertData( table: "Pilotes", - columns: new[] { "Id", "Email", "IdEcurie", "Password", "Pseudo" }, - values: new object[] { 1, "test@gmail.com", null, "7NcYcNGWMxapfjrDQIyYNa2M8PPBvHA1J8MCZVNPda4=", "test_PILOTE" }); + columns: new[] { "Id", "Email", "Password", "Pseudo" }, + values: new object[] { 1, "test@gmail.com", "7NcYcNGWMxapfjrDQIyYNa2M8PPBvHA1J8MCZVNPda4=", "test_PILOTE" }); migrationBuilder.CreateIndex( name: "IX_Circuits_Name", @@ -199,11 +226,6 @@ namespace Entity_Framework.Migrations column: "Email", unique: true); - migrationBuilder.CreateIndex( - name: "IX_Pilotes_IdEcurie", - table: "Pilotes", - column: "IdEcurie"); - migrationBuilder.CreateIndex( name: "IX_Pilotes_Pseudo", table: "Pilotes", @@ -215,6 +237,16 @@ namespace Entity_Framework.Migrations table: "Points", column: "IdTours"); + migrationBuilder.CreateIndex( + name: "IX_RelationEcuriePilote_EcurieId", + table: "RelationEcuriePilote", + column: "EcurieId"); + + migrationBuilder.CreateIndex( + name: "IX_RelationEcuriePilote_PiloteId", + table: "RelationEcuriePilote", + column: "PiloteId"); + migrationBuilder.CreateIndex( name: "IX_Sessions_IdCircuit", table: "Sessions", @@ -229,32 +261,26 @@ namespace Entity_Framework.Migrations name: "IX_Tours_IdSession", table: "Tours", column: "IdSession"); - - migrationBuilder.AddForeignKey( - name: "FK_Ecuries_Pilotes_IdPiloteProprietaire", - table: "Ecuries", - column: "IdPiloteProprietaire", - principalTable: "Pilotes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.DropForeignKey( - name: "FK_Ecuries_Pilotes_IdPiloteProprietaire", - table: "Ecuries"); - migrationBuilder.DropTable( name: "Images"); migrationBuilder.DropTable( name: "Points"); + migrationBuilder.DropTable( + name: "RelationEcuriePilote"); + migrationBuilder.DropTable( name: "Tours"); + migrationBuilder.DropTable( + name: "Ecuries"); + migrationBuilder.DropTable( name: "Sessions"); @@ -263,9 +289,6 @@ namespace Entity_Framework.Migrations migrationBuilder.DropTable( name: "Pilotes"); - - migrationBuilder.DropTable( - name: "Ecuries"); } } } diff --git a/Sources/Entity_Framework/Migrations/BDDContextModelSnapshot.cs b/Sources/Entity_Framework/Migrations/BDDContextModelSnapshot.cs index ac2d2aa..cb7120f 100644 --- a/Sources/Entity_Framework/Migrations/BDDContextModelSnapshot.cs +++ b/Sources/Entity_Framework/Migrations/BDDContextModelSnapshot.cs @@ -97,9 +97,6 @@ namespace Entity_Framework.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("IdEcurie") - .HasColumnType("INTEGER"); - b.Property("Password") .IsRequired() .HasColumnType("TEXT"); @@ -113,8 +110,6 @@ namespace Entity_Framework.Migrations b.HasIndex("Email") .IsUnique(); - b.HasIndex("IdEcurie"); - b.HasIndex("Pseudo") .IsUnique(); @@ -179,6 +174,33 @@ namespace Entity_Framework.Migrations b.ToTable("Points"); }); + modelBuilder.Entity("Entity_Framework.Entity.Relations.Relation_Pilote_Ecurie", b => + { + b.Property("IdPilote") + .HasColumnType("INTEGER"); + + b.Property("IdEcurie") + .HasColumnType("INTEGER"); + + b.Property("EcurieId") + .HasColumnType("INTEGER"); + + b.Property("Grade") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PiloteId") + .HasColumnType("INTEGER"); + + b.HasKey("IdPilote", "IdEcurie"); + + b.HasIndex("EcurieId"); + + b.HasIndex("PiloteId"); + + b.ToTable("RelationEcuriePilote"); + }); + modelBuilder.Entity("Entity_Framework.Entity.Sessions", b => { b.Property("Id") @@ -256,15 +278,6 @@ namespace Entity_Framework.Migrations b.Navigation("Pilote"); }); - modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b => - { - b.HasOne("Entity_Framework.Entity.Ecuries", "Ecurie") - .WithMany("Pilotes") - .HasForeignKey("IdEcurie"); - - b.Navigation("Ecurie"); - }); - modelBuilder.Entity("Entity_Framework.Entity.Points", b => { b.HasOne("Entity_Framework.Entity.Tours", "Tours") @@ -276,6 +289,25 @@ namespace Entity_Framework.Migrations b.Navigation("Tours"); }); + modelBuilder.Entity("Entity_Framework.Entity.Relations.Relation_Pilote_Ecurie", b => + { + b.HasOne("Entity_Framework.Entity.Ecuries", "Ecurie") + .WithMany("PilotesRelation") + .HasForeignKey("EcurieId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entity_Framework.Entity.Pilotes", "Pilote") + .WithMany("Ecurie") + .HasForeignKey("PiloteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ecurie"); + + b.Navigation("Pilote"); + }); + modelBuilder.Entity("Entity_Framework.Entity.Sessions", b => { b.HasOne("Entity_Framework.Entity.Circuits", "Circuit") @@ -313,11 +345,13 @@ namespace Entity_Framework.Migrations modelBuilder.Entity("Entity_Framework.Entity.Ecuries", b => { - b.Navigation("Pilotes"); + b.Navigation("PilotesRelation"); }); modelBuilder.Entity("Entity_Framework.Entity.Pilotes", b => { + b.Navigation("Ecurie"); + b.Navigation("EcuriePropriétaire") .IsRequired();