#199 : Patch de la suppression des styles lors de la modification d'un titre.

This commit is contained in:
Loic Masi
2026-04-09 13:31:24 +02:00
parent b22f061aa9
commit c3ac3a33ab

View File

@@ -187,12 +187,14 @@ public class DbTitreRepository : ITitreRepository
Titre existingTitre = this.Find(titre.IdTitre); Titre existingTitre = this.Find(titre.IdTitre);
if (existingTitre != null) if (existingTitre != null)
{ {
List<Style> stylesToApply = titre.Styles.ToList();
this.context.Entry(existingTitre).CurrentValues.SetValues(titre); this.context.Entry(existingTitre).CurrentValues.SetValues(titre);
// Relation many-to-many // Relation many-to-many
this.context.Entry(existingTitre).Collection(t => t.Styles).Load(); this.context.Entry(existingTitre).Collection(t => t.Styles).Load();
existingTitre.Styles.Clear(); existingTitre.Styles.Clear();
foreach (var style in titre.Styles) foreach (var style in stylesToApply)
{ {
existingTitre.Styles.Add(style); existingTitre.Styles.Add(style);
} }