From 3d5b3873dfeb07612c9dd02b536bef70547c330d Mon Sep 17 00:00:00 2001 From: Theo DUPIN Date: Mon, 20 Mar 2023 18:18:46 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Mise=20en=20place=20de=20toutes=20les=20tab?= =?UTF-8?q?les=20n=C3=A9cessaires=20au=20jeu=20et=20d=C3=A9but=20des=20tes?= =?UTF-8?q?ts=20dans=20ces=20tables=20dans=20la=20DbConsole?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Tests/DbConsole/DbConsole.csproj | 3 + .../20230212153116_MyMigration.Designer.cs | 53 ------ .../Migrations/20230212153116_MyMigration.cs | 39 ---- .../20230320170448_AllMigrations.Designer.cs | 175 +++++++++++++++++ .../20230320170448_AllMigrations.cs | 151 +++++++++++++++ .../Migrations/SQLiteContextModelSnapshot.cs | 122 ++++++++++++ Sources/Tests/DbConsole/Program.cs | 26 ++- Sources/Tests/DbConsole/projet.Champions.db | Bin 20480 -> 20480 bytes .../Tests/DbConsole/projet.ToutesTables.db | Bin 0 -> 49152 bytes ...ions.db-shm => projet.ToutesTables.db-shm} | Bin ...ions.db-wal => projet.ToutesTables.db-wal} | 0 .../Controllers/PlayerController.cs | 4 +- Sources/Trek12_Lib/CaseEntity.cs | 14 ++ Sources/Trek12_Lib/GameEntity.cs | 22 +++ Sources/Trek12_Lib/GrilleEntity.cs | 21 +++ .../20230212152210_MyMigration.Designer.cs | 54 ------ .../Migrations/20230212152210_MyMigration.cs | 39 ---- .../20230320170231_AllMigrations.Designer.cs | 176 ++++++++++++++++++ .../20230320170231_AllMigrations.cs | 151 +++++++++++++++ .../Migrations/TrekContextModelSnapshot.cs | 122 ++++++++++++ Sources/Trek12_Lib/PlayerEntity.cs | 24 +-- Sources/Trek12_Lib/ScoreEntity.cs | 26 +++ Sources/Trek12_Lib/TrekContext.cs | 30 ++- Sources/Trek12_Lib/TurnEntity.cs | 15 ++ Sources/Trek12_Lib/projet.AllTables.db | Bin 0 -> 49152 bytes Sources/Trek12_Lib/projet.Players.db | Bin 20480 -> 0 bytes 26 files changed, 1063 insertions(+), 204 deletions(-) delete mode 100644 Sources/Tests/DbConsole/Migrations/20230212153116_MyMigration.Designer.cs delete mode 100644 Sources/Tests/DbConsole/Migrations/20230212153116_MyMigration.cs create mode 100644 Sources/Tests/DbConsole/Migrations/20230320170448_AllMigrations.Designer.cs create mode 100644 Sources/Tests/DbConsole/Migrations/20230320170448_AllMigrations.cs create mode 100644 Sources/Tests/DbConsole/projet.ToutesTables.db rename Sources/Tests/DbConsole/{projet.Champions.db-shm => projet.ToutesTables.db-shm} (100%) rename Sources/Tests/DbConsole/{projet.Champions.db-wal => projet.ToutesTables.db-wal} (100%) create mode 100644 Sources/Trek12_Lib/CaseEntity.cs create mode 100644 Sources/Trek12_Lib/GameEntity.cs create mode 100644 Sources/Trek12_Lib/GrilleEntity.cs delete mode 100644 Sources/Trek12_Lib/Migrations/20230212152210_MyMigration.Designer.cs delete mode 100644 Sources/Trek12_Lib/Migrations/20230212152210_MyMigration.cs create mode 100644 Sources/Trek12_Lib/Migrations/20230320170231_AllMigrations.Designer.cs create mode 100644 Sources/Trek12_Lib/Migrations/20230320170231_AllMigrations.cs create mode 100644 Sources/Trek12_Lib/ScoreEntity.cs create mode 100644 Sources/Trek12_Lib/TurnEntity.cs create mode 100644 Sources/Trek12_Lib/projet.AllTables.db delete mode 100644 Sources/Trek12_Lib/projet.Players.db diff --git a/Sources/Tests/DbConsole/DbConsole.csproj b/Sources/Tests/DbConsole/DbConsole.csproj index 92c43c9..ed572bd 100644 --- a/Sources/Tests/DbConsole/DbConsole.csproj +++ b/Sources/Tests/DbConsole/DbConsole.csproj @@ -9,12 +9,15 @@ + + + diff --git a/Sources/Tests/DbConsole/Migrations/20230212153116_MyMigration.Designer.cs b/Sources/Tests/DbConsole/Migrations/20230212153116_MyMigration.Designer.cs deleted file mode 100644 index 629e956..0000000 --- a/Sources/Tests/DbConsole/Migrations/20230212153116_MyMigration.Designer.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DbConsole.Migrations -{ - [DbContext(typeof(SQLiteContext))] - [Migration("20230212153116_MyMigration")] - partial class MyMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => - { - b.Property("PlayerId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("MaxPoints") - .HasColumnType("INTEGER"); - - b.Property("MaxZone") - .HasColumnType("INTEGER"); - - b.Property("NbPlayed") - .HasColumnType("INTEGER"); - - b.Property("NbPoints") - .HasColumnType("INTEGER"); - - b.Property("NbWin") - .HasColumnType("INTEGER"); - - b.Property("Pseudo") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("PlayerId"); - - b.ToTable("Players"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sources/Tests/DbConsole/Migrations/20230212153116_MyMigration.cs b/Sources/Tests/DbConsole/Migrations/20230212153116_MyMigration.cs deleted file mode 100644 index 98d2699..0000000 --- a/Sources/Tests/DbConsole/Migrations/20230212153116_MyMigration.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DbConsole.Migrations -{ - /// - public partial class MyMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Players", - columns: table => new - { - PlayerId = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Pseudo = table.Column(type: "TEXT", nullable: false), - NbWin = table.Column(type: "INTEGER", nullable: false), - NbPlayed = table.Column(type: "INTEGER", nullable: false), - MaxZone = table.Column(type: "INTEGER", nullable: false), - MaxPoints = table.Column(type: "INTEGER", nullable: false), - NbPoints = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Players", x => x.PlayerId); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Players"); - } - } -} diff --git a/Sources/Tests/DbConsole/Migrations/20230320170448_AllMigrations.Designer.cs b/Sources/Tests/DbConsole/Migrations/20230320170448_AllMigrations.Designer.cs new file mode 100644 index 0000000..90b7534 --- /dev/null +++ b/Sources/Tests/DbConsole/Migrations/20230320170448_AllMigrations.Designer.cs @@ -0,0 +1,175 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DbConsole.Migrations +{ + [DbContext(typeof(SQLiteContext))] + [Migration("20230320170448_AllMigrations")] + partial class AllMigrations + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b => + { + b.Property("CaseId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("CaseId"); + + b.ToTable("Case"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Property("GameId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbPlayers") + .HasColumnType("INTEGER"); + + b.HasKey("GameId"); + + b.ToTable("Game"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b => + { + b.Property("GrilleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxChain") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbChains") + .HasColumnType("INTEGER"); + + b.Property("NbZones") + .HasColumnType("INTEGER"); + + b.HasKey("GrilleId"); + + b.ToTable("Grille"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Property("PlayerId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxPoints") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbPlayed") + .HasColumnType("INTEGER"); + + b.Property("NbPoints") + .HasColumnType("INTEGER"); + + b.Property("NbWin") + .HasColumnType("INTEGER"); + + b.Property("Pseudo") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("PlayerId"); + + b.ToTable("Players"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("NbPoints") + .HasColumnType("INTEGER"); + + b.Property("PlayerId") + .HasColumnType("INTEGER"); + + b.HasKey("ScoreId"); + + b.HasIndex("GameId"); + + b.HasIndex("PlayerId"); + + b.ToTable("Score"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b => + { + b.Property("TurnId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiceValue1") + .HasColumnType("INTEGER"); + + b.Property("DiceValue2") + .HasColumnType("INTEGER"); + + b.HasKey("TurnId"); + + b.ToTable("Turn"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.HasOne("EntityFrameWorkLib.GameEntity", "Game") + .WithMany() + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Player"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/Tests/DbConsole/Migrations/20230320170448_AllMigrations.cs b/Sources/Tests/DbConsole/Migrations/20230320170448_AllMigrations.cs new file mode 100644 index 0000000..96b4dd1 --- /dev/null +++ b/Sources/Tests/DbConsole/Migrations/20230320170448_AllMigrations.cs @@ -0,0 +1,151 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DbConsole.Migrations +{ + /// + public partial class AllMigrations : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Case", + columns: table => new + { + CaseId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Value = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Case", x => x.CaseId); + }); + + migrationBuilder.CreateTable( + name: "Game", + columns: table => new + { + GameId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Duration = table.Column(type: "TEXT", nullable: false), + Date = table.Column(type: "TEXT", nullable: false), + NbPlayers = table.Column(type: "INTEGER", nullable: false), + Name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Game", x => x.GameId); + }); + + migrationBuilder.CreateTable( + name: "Grille", + columns: table => new + { + GrilleId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + NbChains = table.Column(type: "INTEGER", nullable: false), + NbZones = table.Column(type: "INTEGER", nullable: false), + MaxChain = table.Column(type: "INTEGER", nullable: false), + MaxZone = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Grille", x => x.GrilleId); + }); + + migrationBuilder.CreateTable( + name: "Players", + columns: table => new + { + PlayerId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Pseudo = table.Column(type: "TEXT", nullable: false), + NbWin = table.Column(type: "INTEGER", nullable: false), + NbPlayed = table.Column(type: "INTEGER", nullable: false), + MaxZone = table.Column(type: "INTEGER", nullable: false), + MaxPoints = table.Column(type: "INTEGER", nullable: false), + NbPoints = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Players", x => x.PlayerId); + }); + + migrationBuilder.CreateTable( + name: "Turn", + columns: table => new + { + TurnId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + DiceValue1 = table.Column(type: "INTEGER", nullable: false), + DiceValue2 = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Turn", x => x.TurnId); + }); + + migrationBuilder.CreateTable( + name: "Score", + columns: table => new + { + ScoreId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + NbPoints = table.Column(type: "INTEGER", nullable: false), + GameId = table.Column(type: "INTEGER", nullable: false), + PlayerId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Score", x => x.ScoreId); + table.ForeignKey( + name: "FK_Score_Game_GameId", + column: x => x.GameId, + principalTable: "Game", + principalColumn: "GameId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Score_Players_PlayerId", + column: x => x.PlayerId, + principalTable: "Players", + principalColumn: "PlayerId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Score_GameId", + table: "Score", + column: "GameId"); + + migrationBuilder.CreateIndex( + name: "IX_Score_PlayerId", + table: "Score", + column: "PlayerId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Case"); + + migrationBuilder.DropTable( + name: "Grille"); + + migrationBuilder.DropTable( + name: "Score"); + + migrationBuilder.DropTable( + name: "Turn"); + + migrationBuilder.DropTable( + name: "Game"); + + migrationBuilder.DropTable( + name: "Players"); + } + } +} diff --git a/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs b/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs index b5a68bd..2ee2875 100644 --- a/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs +++ b/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs @@ -1,4 +1,5 @@ // +using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -15,6 +16,67 @@ namespace DbConsole.Migrations #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b => + { + b.Property("CaseId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("CaseId"); + + b.ToTable("Case"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Property("GameId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbPlayers") + .HasColumnType("INTEGER"); + + b.HasKey("GameId"); + + b.ToTable("Game"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b => + { + b.Property("GrilleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxChain") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbChains") + .HasColumnType("INTEGER"); + + b.Property("NbZones") + .HasColumnType("INTEGER"); + + b.HasKey("GrilleId"); + + b.ToTable("Grille"); + }); + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => { b.Property("PlayerId") @@ -44,6 +106,66 @@ namespace DbConsole.Migrations b.ToTable("Players"); }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("NbPoints") + .HasColumnType("INTEGER"); + + b.Property("PlayerId") + .HasColumnType("INTEGER"); + + b.HasKey("ScoreId"); + + b.HasIndex("GameId"); + + b.HasIndex("PlayerId"); + + b.ToTable("Score"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b => + { + b.Property("TurnId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiceValue1") + .HasColumnType("INTEGER"); + + b.Property("DiceValue2") + .HasColumnType("INTEGER"); + + b.HasKey("TurnId"); + + b.ToTable("Turn"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.HasOne("EntityFrameWorkLib.GameEntity", "Game") + .WithMany() + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Player"); + }); #pragma warning restore 612, 618 } } diff --git a/Sources/Tests/DbConsole/Program.cs b/Sources/Tests/DbConsole/Program.cs index c406084..cd00908 100644 --- a/Sources/Tests/DbConsole/Program.cs +++ b/Sources/Tests/DbConsole/Program.cs @@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore; PlayerEntity p1 = new PlayerEntity { + PlayerId = 0, Pseudo = "Jax", NbWin = 0, NbPlayed = 0, @@ -11,8 +12,14 @@ PlayerEntity p1 = new PlayerEntity NbPoints = 0 }; +GameEntity g1 = new GameEntity +{ + GameId = 1, +}; + PlayerEntity p2 = new PlayerEntity { + PlayerId = 0, Pseudo = "Theo", NbWin = 0, NbPlayed = 0, @@ -21,12 +28,25 @@ PlayerEntity p2 = new PlayerEntity NbPoints = 0 }; -using (var context = new SQLiteContext()) +/*using (var context = new SQLiteContext()) { - Console.WriteLine("Create and Insert new Champion"); + Console.WriteLine("Create and Insert new Player"); context.Add(p1); context.Add(p2); context.SaveChanges(); +}*/ + +using (var context = new SQLiteContext()) +{ + var newScore = new ScoreEntity + { + GameId = 1, + PlayerId = 2, + NbPoints = 5 + }; + + context.Add(newScore); + context.SaveChanges(); } public class SQLiteContext : TrekContext @@ -35,7 +55,7 @@ public class SQLiteContext : TrekContext { if (!options.IsConfigured) { - options.UseSqlite($"Data Source=projet.Champions.db"); + options.UseSqlite($"Data Source=projet.ToutesTables.db"); } } } diff --git a/Sources/Tests/DbConsole/projet.Champions.db b/Sources/Tests/DbConsole/projet.Champions.db index bcf72035f7649364288b76cd81caf0311d68965c..67a5f99589231e674b1b3f31602a7f7bf0d2ddaa 100644 GIT binary patch delta 178 zcmZozz}T>WaRZBi3=e-i1OI3KXZ$z$PxJ5N-@w0^e=2_me-(c&fBa@a0ek*>9v%(` zQ4SCY$wWaRZA14-5Zk2L8|d&-ichpWZAeu$zDLX?qg^Miv0hB@1o< diff --git a/Sources/Tests/DbConsole/projet.ToutesTables.db b/Sources/Tests/DbConsole/projet.ToutesTables.db new file mode 100644 index 0000000000000000000000000000000000000000..4c892c43704255dc8f6401ecba2b011363c38e22 GIT binary patch literal 49152 zcmeI*&u`jh7{GCxq#=RO>{3~653{Ttf?A~{>BNp>;H0Qv7@=KKX+lo$HcJ!~3|f2G zp~^;J<4qTtE7`Jl>5JL{d)h? z%-@^;r2kC)yzyJ|zvM5Xm<0g@5I_KdTPyG;y{0|W)F0e#+j&<$ZXKQV`cA9fvEMuW za@*h9EH=zS)6~mW$voDLiAsiEvvk9+YUtZW)Yiy0Q)}82O&!MjKD6IDVbAFqJqK0B z`V9-Smz9mArfKR=-w*85j^iKKe@cbDH49%<%&P%qQo2}z@s-<#2%~8pnho8mHFfJ% zrJ@&W)={%j5aqg2e;EiEdc9Gu78)n|OY=l8ylU3Umgv4}TFs|nht_Gm=XM9)WRFpe zD2(wVM*Bxn6JrW%Tp!s%II@=P)qj$~9Ml?S`Oxx5xot#5dc!<08>Uq>k95CK&dX@0 zn5~joF~y7)3rEF5$((nzV2s`C4>C{UN6w_OAByWq?ZE@}!u6-K zIqY}kx)GmDStL3O>E+f{2-HeonH!A$}hHC-4}-E)TRo}o9*W0B@zsz-@uoqpvC&RKaWGFzViQ_hvB zgR1@RO|R?B?m|>pbau=>f23!6EvY?xs9px1hkduxaf0V$Tr()V%8g+ACYVvng_hQ7 z@jKh?&Ng7EPBm@77&RGuT=J^viJEc@9d&t$o-jY){2YYt-TMhbqbg$AWz z-yXOtuv8V0|v#CEv$MVMzYb~O#uZpjaC+dkGvv=MR_j@hRIUhRRGiPk` zUQA+a=XO_g|5UWhet5JJeAZ}wpGDhqo9PTyN0pzn@x|h!1~iovV08eafI>z^+5I_I{1Q0*~0R#|00D)U7@bQYdG4F=}^7sGZkN#N@KmY**5I_I{ z1Q0*~0R#|0V2K5||6k(CB{T#OKmY**5I_I{1Q0*~0R%z;?*B;z1Q0*~0R#|0009IL zKmY**mS2GT|K*=!B18ZI1Q0*~0R#|0009ILK!E#yasUAY5I_I{1Q0*~0R#|00Di)KmY**5I_I{1Q0*~0R#}>{+}E`009ILKmY**5I_I{1Q0-A`2|ukME?KZ z@=r7oB7gt_2q1s}0tg_000IcyX#wv4@AUK&JOT(HfB*srAb Delete(int idPlayer) { var playerToDelete = await playersManager.GetItemsById(idPlayer); - if (playerToDelete == null) + if(playerToDelete == null) { return NotFound("Joueur non trouvé"); } - if (!await playersManager.DeleteItem(playerToDelete.SingleOrDefault(p => p.Id == idPlayer))) + if(!await playersManager.DeleteItem(playerToDelete.SingleOrDefault(p => p.Id == idPlayer))) { return BadRequest("Erreur lors de la suppression du joueur"); } diff --git a/Sources/Trek12_Lib/CaseEntity.cs b/Sources/Trek12_Lib/CaseEntity.cs new file mode 100644 index 0000000..8a42c6c --- /dev/null +++ b/Sources/Trek12_Lib/CaseEntity.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EntityFrameWorkLib +{ + public class CaseEntity + { + public int CaseId { get; set; } + public int Value { get; set; } + } +} diff --git a/Sources/Trek12_Lib/GameEntity.cs b/Sources/Trek12_Lib/GameEntity.cs new file mode 100644 index 0000000..3648488 --- /dev/null +++ b/Sources/Trek12_Lib/GameEntity.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EntityFrameWorkLib +{ + public class GameEntity + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int GameId { get; set; } + public TimeSpan Duration { get; set; } + public DateOnly Date { get; set; } + public int NbPlayers { get; set; } + public string Name { get; set; } + //public ICollection NbPoints { get; set; } + } +} diff --git a/Sources/Trek12_Lib/GrilleEntity.cs b/Sources/Trek12_Lib/GrilleEntity.cs new file mode 100644 index 0000000..535437d --- /dev/null +++ b/Sources/Trek12_Lib/GrilleEntity.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EntityFrameWorkLib +{ + public class GrilleEntity + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int GrilleId { get; set; } + public int NbChains { get; set; } + public int NbZones { get; set; } + public int MaxChain { get; set; } + public int MaxZone { get; set; } + } +} diff --git a/Sources/Trek12_Lib/Migrations/20230212152210_MyMigration.Designer.cs b/Sources/Trek12_Lib/Migrations/20230212152210_MyMigration.Designer.cs deleted file mode 100644 index 1eae5ae..0000000 --- a/Sources/Trek12_Lib/Migrations/20230212152210_MyMigration.Designer.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -using EntityFrameWorkLib; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace EntityFrameWorkLib.Migrations -{ - [DbContext(typeof(TrekContext))] - [Migration("20230212152210_MyMigration")] - partial class MyMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => - { - b.Property("PlayerId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("MaxPoints") - .HasColumnType("INTEGER"); - - b.Property("MaxZone") - .HasColumnType("INTEGER"); - - b.Property("NbPlayed") - .HasColumnType("INTEGER"); - - b.Property("NbPoints") - .HasColumnType("INTEGER"); - - b.Property("NbWin") - .HasColumnType("INTEGER"); - - b.Property("Pseudo") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("PlayerId"); - - b.ToTable("Players"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sources/Trek12_Lib/Migrations/20230212152210_MyMigration.cs b/Sources/Trek12_Lib/Migrations/20230212152210_MyMigration.cs deleted file mode 100644 index 704ad5f..0000000 --- a/Sources/Trek12_Lib/Migrations/20230212152210_MyMigration.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace EntityFrameWorkLib.Migrations -{ - /// - public partial class MyMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Players", - columns: table => new - { - PlayerId = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Pseudo = table.Column(type: "TEXT", nullable: false), - NbWin = table.Column(type: "INTEGER", nullable: false), - NbPlayed = table.Column(type: "INTEGER", nullable: false), - MaxZone = table.Column(type: "INTEGER", nullable: false), - MaxPoints = table.Column(type: "INTEGER", nullable: false), - NbPoints = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Players", x => x.PlayerId); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Players"); - } - } -} diff --git a/Sources/Trek12_Lib/Migrations/20230320170231_AllMigrations.Designer.cs b/Sources/Trek12_Lib/Migrations/20230320170231_AllMigrations.Designer.cs new file mode 100644 index 0000000..b99d4b8 --- /dev/null +++ b/Sources/Trek12_Lib/Migrations/20230320170231_AllMigrations.Designer.cs @@ -0,0 +1,176 @@ +// +using System; +using EntityFrameWorkLib; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFrameWorkLib.Migrations +{ + [DbContext(typeof(TrekContext))] + [Migration("20230320170231_AllMigrations")] + partial class AllMigrations + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b => + { + b.Property("CaseId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("CaseId"); + + b.ToTable("Case"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Property("GameId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbPlayers") + .HasColumnType("INTEGER"); + + b.HasKey("GameId"); + + b.ToTable("Game"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b => + { + b.Property("GrilleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxChain") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbChains") + .HasColumnType("INTEGER"); + + b.Property("NbZones") + .HasColumnType("INTEGER"); + + b.HasKey("GrilleId"); + + b.ToTable("Grille"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Property("PlayerId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxPoints") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbPlayed") + .HasColumnType("INTEGER"); + + b.Property("NbPoints") + .HasColumnType("INTEGER"); + + b.Property("NbWin") + .HasColumnType("INTEGER"); + + b.Property("Pseudo") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("PlayerId"); + + b.ToTable("Players"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("NbPoints") + .HasColumnType("INTEGER"); + + b.Property("PlayerId") + .HasColumnType("INTEGER"); + + b.HasKey("ScoreId"); + + b.HasIndex("GameId"); + + b.HasIndex("PlayerId"); + + b.ToTable("Score"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b => + { + b.Property("TurnId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiceValue1") + .HasColumnType("INTEGER"); + + b.Property("DiceValue2") + .HasColumnType("INTEGER"); + + b.HasKey("TurnId"); + + b.ToTable("Turn"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.HasOne("EntityFrameWorkLib.GameEntity", "Game") + .WithMany() + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Player"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/Trek12_Lib/Migrations/20230320170231_AllMigrations.cs b/Sources/Trek12_Lib/Migrations/20230320170231_AllMigrations.cs new file mode 100644 index 0000000..5790c46 --- /dev/null +++ b/Sources/Trek12_Lib/Migrations/20230320170231_AllMigrations.cs @@ -0,0 +1,151 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EntityFrameWorkLib.Migrations +{ + /// + public partial class AllMigrations : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Case", + columns: table => new + { + CaseId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Value = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Case", x => x.CaseId); + }); + + migrationBuilder.CreateTable( + name: "Game", + columns: table => new + { + GameId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Duration = table.Column(type: "TEXT", nullable: false), + Date = table.Column(type: "TEXT", nullable: false), + NbPlayers = table.Column(type: "INTEGER", nullable: false), + Name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Game", x => x.GameId); + }); + + migrationBuilder.CreateTable( + name: "Grille", + columns: table => new + { + GrilleId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + NbChains = table.Column(type: "INTEGER", nullable: false), + NbZones = table.Column(type: "INTEGER", nullable: false), + MaxChain = table.Column(type: "INTEGER", nullable: false), + MaxZone = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Grille", x => x.GrilleId); + }); + + migrationBuilder.CreateTable( + name: "Players", + columns: table => new + { + PlayerId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Pseudo = table.Column(type: "TEXT", nullable: false), + NbWin = table.Column(type: "INTEGER", nullable: false), + NbPlayed = table.Column(type: "INTEGER", nullable: false), + MaxZone = table.Column(type: "INTEGER", nullable: false), + MaxPoints = table.Column(type: "INTEGER", nullable: false), + NbPoints = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Players", x => x.PlayerId); + }); + + migrationBuilder.CreateTable( + name: "Turn", + columns: table => new + { + TurnId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + DiceValue1 = table.Column(type: "INTEGER", nullable: false), + DiceValue2 = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Turn", x => x.TurnId); + }); + + migrationBuilder.CreateTable( + name: "Score", + columns: table => new + { + ScoreId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + NbPoints = table.Column(type: "INTEGER", nullable: false), + GameId = table.Column(type: "INTEGER", nullable: false), + PlayerId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Score", x => x.ScoreId); + table.ForeignKey( + name: "FK_Score_Game_GameId", + column: x => x.GameId, + principalTable: "Game", + principalColumn: "GameId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Score_Players_PlayerId", + column: x => x.PlayerId, + principalTable: "Players", + principalColumn: "PlayerId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Score_GameId", + table: "Score", + column: "GameId"); + + migrationBuilder.CreateIndex( + name: "IX_Score_PlayerId", + table: "Score", + column: "PlayerId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Case"); + + migrationBuilder.DropTable( + name: "Grille"); + + migrationBuilder.DropTable( + name: "Score"); + + migrationBuilder.DropTable( + name: "Turn"); + + migrationBuilder.DropTable( + name: "Game"); + + migrationBuilder.DropTable( + name: "Players"); + } + } +} diff --git a/Sources/Trek12_Lib/Migrations/TrekContextModelSnapshot.cs b/Sources/Trek12_Lib/Migrations/TrekContextModelSnapshot.cs index a66ff04..c577c75 100644 --- a/Sources/Trek12_Lib/Migrations/TrekContextModelSnapshot.cs +++ b/Sources/Trek12_Lib/Migrations/TrekContextModelSnapshot.cs @@ -1,4 +1,5 @@ // +using System; using EntityFrameWorkLib; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -16,6 +17,67 @@ namespace EntityFrameWorkLib.Migrations #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b => + { + b.Property("CaseId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("CaseId"); + + b.ToTable("Case"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Property("GameId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbPlayers") + .HasColumnType("INTEGER"); + + b.HasKey("GameId"); + + b.ToTable("Game"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b => + { + b.Property("GrilleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxChain") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbChains") + .HasColumnType("INTEGER"); + + b.Property("NbZones") + .HasColumnType("INTEGER"); + + b.HasKey("GrilleId"); + + b.ToTable("Grille"); + }); + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => { b.Property("PlayerId") @@ -45,6 +107,66 @@ namespace EntityFrameWorkLib.Migrations b.ToTable("Players"); }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("NbPoints") + .HasColumnType("INTEGER"); + + b.Property("PlayerId") + .HasColumnType("INTEGER"); + + b.HasKey("ScoreId"); + + b.HasIndex("GameId"); + + b.HasIndex("PlayerId"); + + b.ToTable("Score"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b => + { + b.Property("TurnId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiceValue1") + .HasColumnType("INTEGER"); + + b.Property("DiceValue2") + .HasColumnType("INTEGER"); + + b.HasKey("TurnId"); + + b.ToTable("Turn"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.HasOne("EntityFrameWorkLib.GameEntity", "Game") + .WithMany() + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player") + .WithMany() + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Player"); + }); #pragma warning restore 612, 618 } } diff --git a/Sources/Trek12_Lib/PlayerEntity.cs b/Sources/Trek12_Lib/PlayerEntity.cs index 174b399..516ca91 100644 --- a/Sources/Trek12_Lib/PlayerEntity.cs +++ b/Sources/Trek12_Lib/PlayerEntity.cs @@ -2,17 +2,19 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace EntityFrameWorkLib; -public class PlayerEntity +namespace EntityFrameWorkLib { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int PlayerId {get; set;} - public string Pseudo { get; set; } - public int NbWin { get; set; } - public int NbPlayed { get; set; } - public int MaxZone { get; set; } - public int MaxPoints { get; set; } - public int NbPoints { get; set; } + public class PlayerEntity + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int PlayerId { get; set; } + public string Pseudo { get; set; } + public int NbWin { get; set; } + public int NbPlayed { get; set; } + public int MaxZone { get; set; } + public int MaxPoints { get; set; } + public int NbPoints { get; set; } + } } diff --git a/Sources/Trek12_Lib/ScoreEntity.cs b/Sources/Trek12_Lib/ScoreEntity.cs new file mode 100644 index 0000000..6e81feb --- /dev/null +++ b/Sources/Trek12_Lib/ScoreEntity.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EntityFrameWorkLib +{ + public class ScoreEntity + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int ScoreId { get; set; } + public int NbPoints { get; set; } + + public int GameId { get; set; } + [ForeignKey("GameId")] + public GameEntity Game { get; set; } + + public int PlayerId { get; set; } + [ForeignKey("PlayerId")] + public PlayerEntity Player { get; set; } + } +} diff --git a/Sources/Trek12_Lib/TrekContext.cs b/Sources/Trek12_Lib/TrekContext.cs index d1d3a57..87d1a91 100644 --- a/Sources/Trek12_Lib/TrekContext.cs +++ b/Sources/Trek12_Lib/TrekContext.cs @@ -10,6 +10,16 @@ namespace EntityFrameWorkLib { public DbSet Players { get; set; } + public DbSet Game { get; set; } + + public DbSet Grille { get; set; } + + public DbSet Case { get; set; } + + public DbSet Turn { get; set; } + + public DbSet Score { get; set; } + public TrekContext() { } public TrekContext(DbContextOptions options) : base(options) @@ -18,21 +28,35 @@ namespace EntityFrameWorkLib { if (!options.IsConfigured) { - base.OnConfiguring(options.UseSqlite($"DataSource=projet.Players.db")); + base.OnConfiguring(options.UseSqlite($"DataSource=projet.AllTables.db")); } } + protected override void OnModelCreating(ModelBuilder modelBuilder) { //Définition de la clé primaire de PlayerEntity modelBuilder.Entity().HasKey(n => n.PlayerId); + //Définition de la clé primaire de GameEntity + modelBuilder.Entity().HasKey(n => n.GameId); + //Définition de la clé primaire de GrilleEntity + modelBuilder.Entity().HasKey(n => n.GrilleId); + //Définition de la clé primaire de CaseEntity + modelBuilder.Entity().HasKey(n => n.CaseId); + //Définition de la clé primaire de TurnEntity + modelBuilder.Entity().HasKey(n => n.TurnId); + //Définition de la clé primaire de ScoreEntity + modelBuilder.Entity().HasKey(n => n.ScoreId); //Définition du mode de generation de la clé : génération à l'insertion modelBuilder.Entity().Property(n => n.PlayerId).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(n => n.GameId).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(n => n.GrilleId).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(n => n.CaseId).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(n => n.TurnId).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(n => n.ScoreId).ValueGeneratedOnAdd(); base.OnModelCreating(modelBuilder); - } - } } diff --git a/Sources/Trek12_Lib/TurnEntity.cs b/Sources/Trek12_Lib/TurnEntity.cs new file mode 100644 index 0000000..b82d23e --- /dev/null +++ b/Sources/Trek12_Lib/TurnEntity.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EntityFrameWorkLib +{ + public class TurnEntity + { + public int TurnId { get; set; } + public int DiceValue1 { get; set; } + public int DiceValue2 { get; set; } + } +} diff --git a/Sources/Trek12_Lib/projet.AllTables.db b/Sources/Trek12_Lib/projet.AllTables.db new file mode 100644 index 0000000000000000000000000000000000000000..1dcbc420cb6bf652282f9816e0c17d4edbe49560 GIT binary patch literal 49152 zcmeI*&u`jh7{GCxq#=;d>{3~653{Tt61B<_qKWGmI4LR^MrfB*nvemMZM_ci2eVZg87_x1aH-p61kk#hQF*&R6gH@*H_ zd!QdFA1R51^0}@nijolPwpgPjCElz@8{$>H^?ugdgtFg!lG*uJ*-E}p9{#@b>%-47 ze{cV@^=JC$)NjfElD~*z76cGL009KOE>(ghQ4b=ZH>J~dP94rsl#~RC-z$>?0IWO&q0;3 ze#64O>vAfoX`1@e_XE4tas1=@PwB9?M*fSkc{89)S{F+&zEax|VKmGWv#wj!hHkwo zm-Rx`I&IYRqFgs>F9QKXuhmPHeEnR1X`bu(SB+}P65Ur!tMNSS&}!9sZg=2K_88TO z!Wchdw0|TuF{ZG_?U5aaBWucD{U;gBakXxiPAq?vyGBH$*Ue+IZdwKNRQC(zyo`2= z*(#c4Q_N@~e_F^F&3Q))#^{YQV*HS!81`ZZ4V%UDLFP&P$eHxshr(u3d-O=Xa{cLS z4EtTVrs9(+i$rH3z1&)6DuY%FXR_#CIIr!_&^eqvm!mq_$vPs6t4cDdJ$Uysk_2#>d(=!{4vB@i>Pbs;_Ks?dhW;UU3SF%Uej|fhfepx8QXji zlNj5%+ZEkE7cKWbJXs4qYc#*lg6%nSU5~XkWYLYI+*-ylXtmJM|D2i30y)WNYEsMP z)T^pLxMtHluDIU@>fQ_28}$0`rxqsS!=GB`CZ18BGN>5&_!r@fj&6k*eH_&Kz4q{8 z@Y?BnlPMxXDr-5GG^ZY?c{sIrOw`~TISVkh4}vS?RV4cbbN>Sa}#wcMBW#$Q&gzhTdRH}31dsDc6k2tWV=5P$##AOHafKw!HB z2Gw2V=tvr+-gxRKH&c3#aufe%=7*P?&7D(Q=#Joy{;ntZM(kneUHiwhXY)=}_LPGI z>8H2MIhcBLKTfhubuEXQ^{V`^#;Ig&W1@1ya>NH=bF1%gYuM}Y)4p}#*gEx7*twhU zIj{{=w@3V3jJQ5@`i4bQn8I?7vy_QHn?x#i#23nxWy{8_@#i4?f3AFVIZ466WC5mk z`!x#v(gZXn4ASk8pZR%PI=w9 zFeVqzQ!dcgj5ftf@;vfiiO11ocA0*nt4@cyk+s$|jOG7Z;}n0SG_<0uX=z1Rwwb2tWV= I5Xc1n0jN6mL;wH) From faa3d625f1ff8101177cdfd21c4021b4298a9a58 Mon Sep 17 00:00:00 2001 From: Maxence LANONE Date: Mon, 20 Mar 2023 20:53:42 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index d445b9b..02f2027 100644 --- a/.drone.yml +++ b/.drone.yml @@ -54,7 +54,7 @@ steps: dockerfile: Sources/Trek12_API/Dockerfile context: Sources/ registry: hub.codefirst.iut.uca.fr - repo: hub.codefirst.iut.uca.fr/Trek_Prod/Trek12_API + repo: hub.codefirst.iut.uca.fr/trek_prod/trek12_api username: from_secret: SECRET_REGISTRY_USERNAME password: @@ -64,7 +64,7 @@ steps: - name: deploy-container image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: - IMAGENAME: hub.codefirst.iut.uca.fr/Trek_Prod/Trek12_API:latest + IMAGENAME: hub.codefirst.iut.uca.fr/trek_prod/trek12_api:latest CONTAINERNAME: trek12api COMMAND: create OVERWRITE: true