Agliullov D. A. Lab Work 6 Hard #18

Closed
d.agliullov wants to merge 53 commits from Lab6_Hard into Lab5_Hard
Showing only changes of commit 7261bc6914 - Show all commits

View File

@ -106,16 +106,12 @@ namespace ConfectioneryDatabaseImplement.Models
}
}
var shop = context.Shops.First(x => x.Id == model.Id);
foreach (var pc in model.Pastries)
{
context.PastryComponents.Add(new()
{
Pastry = context.Pastries.First(y => y.Id == pc.Key),
Count = pc.Value.Item2,
});
context.SaveChanges();
}
context.SaveChanges();
shop.ShopPastries.AddRange(model.Pastries.Select(x => new ShopPastry
{
Pastry = context.Pastries.First(y => y.Id == x.Key),
Count = x.Value.Item2,
}).Except(shopPastries ?? new()));
context.SaveChanges();
_cachedPastries = null;
}
}