From e0f7c1012615d14c3fef84c117f613d21c6eed47 Mon Sep 17 00:00:00 2001 From: victor perez ngounou Date: Tue, 25 Oct 2022 15:32:13 +0200 Subject: [PATCH 1/4] Modification de la metode add dans joueurDbDataManageur #67 --- Sources/BowlingApp/BowlingApp.csproj | 1 + Sources/BowlingApp/Match.cs | 35 +++++++++---- Sources/BowlingApp/bowling.db | Bin 45056 -> 45056 bytes Sources/BowlingEF/Context/BowlingContext.cs | 2 +- Sources/BowlingEF/Entities/FrameEntity.cs | 7 --- Sources/BowlingEF/Entities/JoueurEntity.cs | 1 + Sources/BowlingEF/Entities/PartieEntity.cs | 6 +-- Sources/BowlingLib/Model/Frame.cs | 2 +- Sources/BowlingLib/Model/Joueur.cs | 11 ++++ Sources/BowlingLib/Model/Partie.cs | 3 +- Sources/BowlingMaping/JoueurDbDataManager.cs | 52 ++++++++++++++++--- Sources/BowlingMaping/PartieDbDataManager.cs | 15 ++++-- 12 files changed, 103 insertions(+), 32 deletions(-) diff --git a/Sources/BowlingApp/BowlingApp.csproj b/Sources/BowlingApp/BowlingApp.csproj index d267dee..9f13908 100644 --- a/Sources/BowlingApp/BowlingApp.csproj +++ b/Sources/BowlingApp/BowlingApp.csproj @@ -3,6 +3,7 @@ Exe net6.0 + $(MSBuildProjectDirectory) diff --git a/Sources/BowlingApp/Match.cs b/Sources/BowlingApp/Match.cs index 66470be..fb074e9 100644 --- a/Sources/BowlingApp/Match.cs +++ b/Sources/BowlingApp/Match.cs @@ -63,7 +63,13 @@ namespace BowlingApp /// public static void JeuIndividuel(Saissiseur saissiseur) { - + // Création des parties pour chaque joueur + Manager manager = new Manager(new EquipeDbDataManager(), new PartieDbDataManager(), new JoueurDbDataManager()); + List j2 = (List)manager.GetAllJoueur().Result; + j2.ForEach(joueur => + { + Console.WriteLine(joueur.Pseudo); + }); Afficheur.InviteNrb("Joueur"); int nbrj = saissiseur.CollecteNbr(); List joueurs = new List(); @@ -78,8 +84,7 @@ namespace BowlingApp } - // Création des parties pour chaque joueur - Manager manager = new Manager(new EquipeDbDataManager(), new PartieDbDataManager(), new JoueurDbDataManager()); + for (int i = 0; i < joueurs.Count; i++) { @@ -119,16 +124,17 @@ namespace BowlingApp Joueur joueur = new Joueur(Nom); Partie partie = new Partie(joueur); Manager manager = new Manager(new EquipeDbDataManager(), new PartieDbDataManager(), new JoueurDbDataManager()); - manager.AddJoueur(joueur); Lancer(partie, saissiseur); - manager.AddPartie(partie); + joueur.AddPartie(partie); + //manager.AddPartie(partie); + manager.AddJoueur(joueur); } /// /// Faire des lancers /// /// - /// + /// FnEP~Z$ZXEhhQxU)24qv~Wk z4lypb{G!y%^gQp>%E@6I>d4%B4sm4e4368JqU`MAl9G&VtdnavKTgi#<(j;YYYJyB z8@sr)G-Ipb$;-JWbB409i%Uy0wlYq3=5A*K z+5uEF`5kwh6v!So{~%XScRvMh*GMF5Hka`f2(ud*ni!ZHnQne7|DPYu`K-^|007t% BNXGyG diff --git a/Sources/BowlingEF/Context/BowlingContext.cs b/Sources/BowlingEF/Context/BowlingContext.cs index dcd5491..8c93437 100644 --- a/Sources/BowlingEF/Context/BowlingContext.cs +++ b/Sources/BowlingEF/Context/BowlingContext.cs @@ -20,7 +20,7 @@ namespace BowlingEF.Context protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlite("Data Source=C:\\Users\\DELL\\BowlingScoreApp\\Sources\\BowlingApp\\bowling.db"); + optionsBuilder.UseSqlite("Data Source=bowling.db"); } } diff --git a/Sources/BowlingEF/Entities/FrameEntity.cs b/Sources/BowlingEF/Entities/FrameEntity.cs index b3c5c35..0c0b519 100644 --- a/Sources/BowlingEF/Entities/FrameEntity.cs +++ b/Sources/BowlingEF/Entities/FrameEntity.cs @@ -19,14 +19,7 @@ namespace BowlingEF.Entities [Required] public int Lancer2 { get; set; } public int Lancer3 { get; set; } - [Required] - public bool IsStrike { get; set; } - [Required] - public bool IsSpare { get; set; } - [ForeignKey("PartieId")] - [Required] - public long PartieId { get; set; } public PartieEntity Partie { get; set; } #endregion } diff --git a/Sources/BowlingEF/Entities/JoueurEntity.cs b/Sources/BowlingEF/Entities/JoueurEntity.cs index d958661..ee2e708 100644 --- a/Sources/BowlingEF/Entities/JoueurEntity.cs +++ b/Sources/BowlingEF/Entities/JoueurEntity.cs @@ -15,6 +15,7 @@ namespace BowlingEF.Entities [Required] public string Pseudo { get; set; } + public ICollection PartieEntities { get; set; } = new List(); #endregion } } \ No newline at end of file diff --git a/Sources/BowlingEF/Entities/PartieEntity.cs b/Sources/BowlingEF/Entities/PartieEntity.cs index 54b799b..4929b51 100644 --- a/Sources/BowlingEF/Entities/PartieEntity.cs +++ b/Sources/BowlingEF/Entities/PartieEntity.cs @@ -17,11 +17,9 @@ namespace BowlingEF.Entities [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Id { get; set; } - public JoueurEntity Joueur { get; set; } - [ForeignKey("JoueurId")] - [Required] - public long JoueurId { get; set; } + [ForeignKey("JoueurForeignKey")] + public JoueurEntity Joueur { get; set; } [Required] public DateTime Date { get; set; } public ICollection Frames { get; set; } diff --git a/Sources/BowlingLib/Model/Frame.cs b/Sources/BowlingLib/Model/Frame.cs index 2e3f41c..5b5696c 100644 --- a/Sources/BowlingLib/Model/Frame.cs +++ b/Sources/BowlingLib/Model/Frame.cs @@ -149,7 +149,7 @@ namespace BowlingLib.Model /// /// /// - public Frame(long id, int numero, int lancer1, int lancer2, [AllowNull] int lancer3) : this(numero) + public Frame(long id, int numero, int lancer1, int lancer2, int lancer3) : this(numero) { this.id = id; Lancer1 = new Lancer(lancer1); diff --git a/Sources/BowlingLib/Model/Joueur.cs b/Sources/BowlingLib/Model/Joueur.cs index 21059d9..af1132c 100644 --- a/Sources/BowlingLib/Model/Joueur.cs +++ b/Sources/BowlingLib/Model/Joueur.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Collections.ObjectModel; + namespace BowlingLib.Model { /// @@ -14,12 +16,16 @@ namespace BowlingLib.Model #region Propriétés private string pseudo; private readonly long id; + + private readonly List parties=new(); + public ReadOnlyCollection Parties { get; } #endregion #region Constructeurs public Joueur(string pseudo) { this.Pseudo = pseudo; + Parties = new ReadOnlyCollection(parties); } public Joueur(long id, string pseudo) : this(pseudo) @@ -76,6 +82,11 @@ namespace BowlingLib.Model return Pseudo.GetHashCode(); } + public void AddPartie(Partie p) + { + parties.Add(p); + } + #endregion } } diff --git a/Sources/BowlingLib/Model/Partie.cs b/Sources/BowlingLib/Model/Partie.cs index 88f4fdc..5216a21 100644 --- a/Sources/BowlingLib/Model/Partie.cs +++ b/Sources/BowlingLib/Model/Partie.cs @@ -46,7 +46,7 @@ namespace BowlingLib.Model public Partie(Joueur joueur) { this.Joueur = joueur; - + Date = DateTime.Now; Frames = new ReadOnlyCollection(frames); } @@ -77,6 +77,7 @@ namespace BowlingLib.Model /// le Score d'une partie public int? GetScore() { + score = 0; for (int i = 0; i < Frames.Count; i++) { score += Frames[i].QuillesTombees; diff --git a/Sources/BowlingMaping/JoueurDbDataManager.cs b/Sources/BowlingMaping/JoueurDbDataManager.cs index 75ddc72..1f467ac 100644 --- a/Sources/BowlingMaping/JoueurDbDataManager.cs +++ b/Sources/BowlingMaping/JoueurDbDataManager.cs @@ -3,8 +3,10 @@ using BowlingEF.Entities; using BowlingLib.Model; using Business; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -27,13 +29,51 @@ namespace BowlingMaping bool result = false; using (var context = new BowlingContext()) { - JoueurEntity entity=new JoueurEntity + try { - Id = _joueur.Id, - Pseudo = _joueur.Pseudo, - }; - context.Joueurs.Add(entity); - result =await context.SaveChangesAsync() == 1; + //Mapping entre la classe joueur et la classe joueurEntity + JoueurEntity entity = new JoueurEntity + { + Id = _joueur.Id, + Pseudo = _joueur.Pseudo, + }; + + //Parcourt de la liste des parties d'un joueur + for (int i = 0; i < _joueur.Parties.Count; i++) + { + //Mapping entre les parties d'un joueur et les partieEntity d'une partieEntity + PartieEntity partieEntity = new PartieEntity + { + Joueur = entity, + Date = _joueur.Parties[i].Date, + Score = _joueur.Parties[i].Score + + }; + + //Parcourt de la liste des frames d'une partie + for (int j = 0; j < _joueur.Parties[i].Frames.Count; j++) + { + //Mapping entre les frames d'une partie et les frameEntity d'une partieEntity + FrameEntity frameEntity = new FrameEntity + { + Id = _joueur.Parties[i].Frames[j].Id, + Lancer1 = _joueur.Parties[i].Frames[j].Lancer1.QuillesTombees, + Lancer2 = _joueur.Parties[i].Frames[j].Lancer2.QuillesTombees, + Lancer3 = (_joueur.Parties[i].Frames[j].Lancer3 == null) ? 0 : _joueur.Parties[i].Frames[j].Lancer3.QuillesTombees,//si Lancer3 est null il prend la valeur Zero + Partie = partieEntity + }; + partieEntity.Frames.Add(frameEntity); + } + entity.PartieEntities.Add(partieEntity); + } + context.Joueurs.Add(entity); + result = await context.SaveChangesAsync() == 1; + } + catch (Exception ex) + { + Debug.WriteLine(ex); + throw; + } } return result; } diff --git a/Sources/BowlingMaping/PartieDbDataManager.cs b/Sources/BowlingMaping/PartieDbDataManager.cs index 4934ccc..deab746 100644 --- a/Sources/BowlingMaping/PartieDbDataManager.cs +++ b/Sources/BowlingMaping/PartieDbDataManager.cs @@ -31,12 +31,21 @@ namespace BowlingMaping { Id = _partie.Id, Date = _partie.Date, - JoueurId = _partie.Joueur.Id, Score = _partie.Score }; context.Parties.Add(entity); - result = await context.SaveChangesAsync() == 1; + try + { + var data = await context.SaveChangesAsync(); + result = data == 1; + } + catch (Exception ex) + { + Console.WriteLine(ex); + throw; + } } + return result; } @@ -69,7 +78,7 @@ namespace BowlingMaping { PartieEntity entity = context.Parties.Find(_partie.Id); entity.Date = _partie.Date; - entity.JoueurId = _partie.Joueur.Id; + //entity.JoueurId = _partie.Joueur.Id; entity.Score = _partie.Score; result =await context.SaveChangesAsync() == 1; } From b870bebbc4377723792876012ef3638f98e36f6f Mon Sep 17 00:00:00 2001 From: "augustin.affognon" Date: Tue, 25 Oct 2022 17:52:46 +0200 Subject: [PATCH 2/4] Correction --- Sources/BowlingApp/Match.cs | 24 ++- Sources/BowlingApp/bowling.db | Bin 45056 -> 45056 bytes .../20221025144845_myMigration.Designer.cs | 154 ++++++++++++++++++ .../Migrations/20221025144845_myMigration.cs | 119 ++++++++++++++ .../Migrations/BowlingContextModelSnapshot.cs | 152 +++++++++++++++++ Sources/BowlingEF/bowling.db | Bin 0 -> 45056 bytes Sources/BowlingMaping/EquipeDbDataManager.cs | 20 ++- 7 files changed, 458 insertions(+), 11 deletions(-) create mode 100644 Sources/BowlingEF/Migrations/20221025144845_myMigration.Designer.cs create mode 100644 Sources/BowlingEF/Migrations/20221025144845_myMigration.cs create mode 100644 Sources/BowlingEF/Migrations/BowlingContextModelSnapshot.cs create mode 100644 Sources/BowlingEF/bowling.db diff --git a/Sources/BowlingApp/Match.cs b/Sources/BowlingApp/Match.cs index fb074e9..3a17c64 100644 --- a/Sources/BowlingApp/Match.cs +++ b/Sources/BowlingApp/Match.cs @@ -63,17 +63,15 @@ namespace BowlingApp /// public static void JeuIndividuel(Saissiseur saissiseur) { + // Création des parties pour chaque joueur Manager manager = new Manager(new EquipeDbDataManager(), new PartieDbDataManager(), new JoueurDbDataManager()); - List j2 = (List)manager.GetAllJoueur().Result; - j2.ForEach(joueur => - { - Console.WriteLine(joueur.Pseudo); - }); + Afficheur.InviteNrb("Joueur"); int nbrj = saissiseur.CollecteNbr(); List joueurs = new List(); + // Création des joueurs for (int j = 0; j < nbrj; j++) { @@ -83,8 +81,8 @@ namespace BowlingApp joueurs.Add(joueur); } + - for (int i = 0; i < joueurs.Count; i++) { @@ -130,6 +128,20 @@ namespace BowlingApp manager.AddJoueur(joueur); } + + private static void CreerPatier() + { + /* Afficheur.InviteNom("Joueur"); + string Nom = saissiseur.CollecteNom(); + Joueur joueur = new Joueur(Nom); + Partie partie = new Partie(joueur); + Manager manager = new Manager(new EquipeDbDataManager(), new PartieDbDataManager(), new JoueurDbDataManager()); + Lancer(partie, saissiseur); + joueur.AddPartie(partie); + //manager.AddPartie(partie); + manager.AddJoueur(joueur);*/ + } + /// /// Faire des lancers /// diff --git a/Sources/BowlingApp/bowling.db b/Sources/BowlingApp/bowling.db index 0f6dee5d189e85c4b1b1fe18f00ff8c3f6b0e558..2e571a64def0470956957a4bb319ccaa23a25f76 100644 GIT binary patch delta 416 zcmZ9Iu}i~16vp4>a!uZ$d}a_4m*U=%#8#y)1wq8gr9;OK9UMeR&20aLE^h9QLUwl- z3*sUaEx3pxf>>NSco)F~mmk0Pj{Ep{!>Ko%dRKm1OH2q~c)_HIs<)_XDObf_);sPG zwD#m0ANI1-BQpr&2Pb(y&jyP`Brqe)iYR`=G7FzpsN3mw_J5yDq=}2~&|Vjcc-Kqg zG_56ZEp1kltyY}0HX8LLO|~1&O**%KG)5*4uXw^eZg7nPm$<;Fh?a7kX&q1~gkYr< zbLpXR4xI*0D^8VD->G!!ITe4Z%R*zq9N+lF`+_;oGam6^x{Xbv0z1BBp)J@Vv4gJX%r4u diff --git a/Sources/BowlingEF/Migrations/20221025144845_myMigration.Designer.cs b/Sources/BowlingEF/Migrations/20221025144845_myMigration.Designer.cs new file mode 100644 index 0000000..b6b58a2 --- /dev/null +++ b/Sources/BowlingEF/Migrations/20221025144845_myMigration.Designer.cs @@ -0,0 +1,154 @@ +// +using System; +using BowlingEF.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BowlingEF.Migrations +{ + [DbContext(typeof(BowlingContext))] + [Migration("20221025144845_myMigration")] + partial class myMigration + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.10"); + + modelBuilder.Entity("BowlingEF.Entities.EquipeEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Nom") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Equipes"); + }); + + modelBuilder.Entity("BowlingEF.Entities.FrameEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Lancer1") + .HasColumnType("INTEGER"); + + b.Property("Lancer2") + .HasColumnType("INTEGER"); + + b.Property("Lancer3") + .HasColumnType("INTEGER"); + + b.Property("Numero") + .HasColumnType("INTEGER"); + + b.Property("PartieId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("PartieId"); + + b.ToTable("Frames"); + }); + + modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EquipeEntityId") + .HasColumnType("INTEGER"); + + b.Property("Pseudo") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("EquipeEntityId"); + + b.ToTable("Joueurs"); + }); + + modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("JoueurForeignKey") + .HasColumnType("INTEGER"); + + b.Property("Score") + .IsRequired() + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("JoueurForeignKey"); + + b.ToTable("Parties"); + }); + + modelBuilder.Entity("BowlingEF.Entities.FrameEntity", b => + { + b.HasOne("BowlingEF.Entities.PartieEntity", "Partie") + .WithMany("Frames") + .HasForeignKey("PartieId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Partie"); + }); + + modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b => + { + b.HasOne("BowlingEF.Entities.EquipeEntity", null) + .WithMany("Joueurs") + .HasForeignKey("EquipeEntityId"); + }); + + modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b => + { + b.HasOne("BowlingEF.Entities.JoueurEntity", "Joueur") + .WithMany("PartieEntities") + .HasForeignKey("JoueurForeignKey") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Joueur"); + }); + + modelBuilder.Entity("BowlingEF.Entities.EquipeEntity", b => + { + b.Navigation("Joueurs"); + }); + + modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b => + { + b.Navigation("PartieEntities"); + }); + + modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b => + { + b.Navigation("Frames"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/BowlingEF/Migrations/20221025144845_myMigration.cs b/Sources/BowlingEF/Migrations/20221025144845_myMigration.cs new file mode 100644 index 0000000..99c5c03 --- /dev/null +++ b/Sources/BowlingEF/Migrations/20221025144845_myMigration.cs @@ -0,0 +1,119 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BowlingEF.Migrations +{ + public partial class myMigration : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Equipes", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Nom = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Equipes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Joueurs", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Pseudo = table.Column(type: "TEXT", nullable: false), + EquipeEntityId = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Joueurs", x => x.Id); + table.ForeignKey( + name: "FK_Joueurs_Equipes_EquipeEntityId", + column: x => x.EquipeEntityId, + principalTable: "Equipes", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Parties", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + JoueurForeignKey = table.Column(type: "INTEGER", nullable: false), + Date = table.Column(type: "TEXT", nullable: false), + Score = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Parties", x => x.Id); + table.ForeignKey( + name: "FK_Parties_Joueurs_JoueurForeignKey", + column: x => x.JoueurForeignKey, + principalTable: "Joueurs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Frames", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Numero = table.Column(type: "INTEGER", nullable: false), + Lancer1 = table.Column(type: "INTEGER", nullable: false), + Lancer2 = table.Column(type: "INTEGER", nullable: false), + Lancer3 = table.Column(type: "INTEGER", nullable: false), + PartieId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Frames", x => x.Id); + table.ForeignKey( + name: "FK_Frames_Parties_PartieId", + column: x => x.PartieId, + principalTable: "Parties", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Frames_PartieId", + table: "Frames", + column: "PartieId"); + + migrationBuilder.CreateIndex( + name: "IX_Joueurs_EquipeEntityId", + table: "Joueurs", + column: "EquipeEntityId"); + + migrationBuilder.CreateIndex( + name: "IX_Parties_JoueurForeignKey", + table: "Parties", + column: "JoueurForeignKey"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Frames"); + + migrationBuilder.DropTable( + name: "Parties"); + + migrationBuilder.DropTable( + name: "Joueurs"); + + migrationBuilder.DropTable( + name: "Equipes"); + } + } +} diff --git a/Sources/BowlingEF/Migrations/BowlingContextModelSnapshot.cs b/Sources/BowlingEF/Migrations/BowlingContextModelSnapshot.cs new file mode 100644 index 0000000..b72dd97 --- /dev/null +++ b/Sources/BowlingEF/Migrations/BowlingContextModelSnapshot.cs @@ -0,0 +1,152 @@ +// +using System; +using BowlingEF.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BowlingEF.Migrations +{ + [DbContext(typeof(BowlingContext))] + partial class BowlingContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.10"); + + modelBuilder.Entity("BowlingEF.Entities.EquipeEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Nom") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Equipes"); + }); + + modelBuilder.Entity("BowlingEF.Entities.FrameEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Lancer1") + .HasColumnType("INTEGER"); + + b.Property("Lancer2") + .HasColumnType("INTEGER"); + + b.Property("Lancer3") + .HasColumnType("INTEGER"); + + b.Property("Numero") + .HasColumnType("INTEGER"); + + b.Property("PartieId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("PartieId"); + + b.ToTable("Frames"); + }); + + modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("EquipeEntityId") + .HasColumnType("INTEGER"); + + b.Property("Pseudo") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("EquipeEntityId"); + + b.ToTable("Joueurs"); + }); + + modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("JoueurForeignKey") + .HasColumnType("INTEGER"); + + b.Property("Score") + .IsRequired() + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("JoueurForeignKey"); + + b.ToTable("Parties"); + }); + + modelBuilder.Entity("BowlingEF.Entities.FrameEntity", b => + { + b.HasOne("BowlingEF.Entities.PartieEntity", "Partie") + .WithMany("Frames") + .HasForeignKey("PartieId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Partie"); + }); + + modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b => + { + b.HasOne("BowlingEF.Entities.EquipeEntity", null) + .WithMany("Joueurs") + .HasForeignKey("EquipeEntityId"); + }); + + modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b => + { + b.HasOne("BowlingEF.Entities.JoueurEntity", "Joueur") + .WithMany("PartieEntities") + .HasForeignKey("JoueurForeignKey") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Joueur"); + }); + + modelBuilder.Entity("BowlingEF.Entities.EquipeEntity", b => + { + b.Navigation("Joueurs"); + }); + + modelBuilder.Entity("BowlingEF.Entities.JoueurEntity", b => + { + b.Navigation("PartieEntities"); + }); + + modelBuilder.Entity("BowlingEF.Entities.PartieEntity", b => + { + b.Navigation("Frames"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/BowlingEF/bowling.db b/Sources/BowlingEF/bowling.db new file mode 100644 index 0000000000000000000000000000000000000000..491eddd6b8769805646b9bd3c81924acaa428de7 GIT binary patch literal 45056 zcmeI)%WmRU7{GCxWWpt7(pe!CMY3E~8Z@IQFqx*6DorUdGc?4cz*NbivS{#(kOpXs zks4K9B)z;vAE1jqMqi-YZmK>-mp!%*7aJ(bGVr$`hU0Vb_dA#5kSL8Ws~y+Y-t?Vr z%hjGK?<=vG@|mV7iV_pgZSfo(3Grfc^hTW3sn?5M#+3cq59ytMl~m%D^6<}{-yasz zf4}$J_9w|-lbchUNfWOdhW+;Jf6vB)nC$X>zj9WkR|wqU_+JWs4qnX`K3v{=8;PK*n!__|rEn4<1e!)!j4m6^k? z?eu3W99^%rdY877UzVY;EW@+K8OA0vQOTQ_j;%b3Z9E7k#mlw2QF&?l!A?_ab)#(5 z4YOo4LW4~}=DY!TY*Y;~Tua49sd#LpQ@PvjRy?!2tNxt#`zB~%AW!jd@5ofqxp(NE zaiOLC6AaPG6kE)A+;VMQYZ~WbM95Jw>cqySn4$|yMtJ4D$;mxC$#pI4JadP+koVLa zTkL)K!1w;?h3_qk$kSHXds5#WyvK!>dY=vKVOz|HxsH)VVlrOE44gk!Wy5l@iY{7F z%1HfT$l&6@TSYubF-*@kw=z$js24uk;Od>&>{$c*YG{io8+rR6gc!N_xF?pjr=n!; zW^cpqh}%bgow7-J+6>hpS4{7I?$8nAAeMH7+3!YrK}39WuEsM*N9t|Ozdy?|%BP*T zPRs4|dxKYq$>XR8`(jvq1*T0TXWm7@^h0n#19(YeqKq7r@Hf(A|4zFAbsKPWuUA0B>u_}uDVk3YBgX#Ze8e~=P!sXPBD;=zFc z0tg_000IagfB*srAbW8E zJ|;p05I_I{1Q0*~0R#|0009Kp|1$; new JoueurEntity - { - Id = j.Id, - Pseudo = j.Pseudo - }).ToList() + }; + + for(int i = 0; i<_equipe.Joueurs.Count; i++) + { + JoueurEntity joueur = new JoueurEntity + { + Id = _equipe.Joueurs[i].Id, + Pseudo = _equipe.Joueurs[i].Pseudo, + Equipe = entity + + }; + + entity.Joueurs.Add(joueur); + } + context.Equipes.Add(entity); result = await context.SaveChangesAsync() == 1; } From 33e3de7207467524ae437468052818b0412db328 Mon Sep 17 00:00:00 2001 From: Augustin AFFOGNON Date: Wed, 26 Oct 2022 07:22:42 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'Sources/Bowlin?= =?UTF-8?q?gMaping/EquipeDbDataManager.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/BowlingMaping/EquipeDbDataManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/BowlingMaping/EquipeDbDataManager.cs b/Sources/BowlingMaping/EquipeDbDataManager.cs index 94bd663..6d36f28 100644 --- a/Sources/BowlingMaping/EquipeDbDataManager.cs +++ b/Sources/BowlingMaping/EquipeDbDataManager.cs @@ -33,7 +33,7 @@ namespace BowlingMaping { Id = _equipe.Joueurs[i].Id, Pseudo = _equipe.Joueurs[i].Pseudo, - Equipe = entity + //Equipe = entity }; From 612a5b3c41477ae798f44b67323fdd51f7957e78 Mon Sep 17 00:00:00 2001 From: Augustin AFFOGNON Date: Wed, 26 Oct 2022 07:26:44 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c82ea9..165d784 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ $ dotnet tool install --global dotnet-ef * Dans la console, tapez la commande suivante: ```shell -Update-Database +$ dotnet ef database update ``` * L'application est prête à être utilisée.