Merge branch 'main' of https://git.is.ulstu.ru/Vyacheslav/CourseWork_Hotel
This commit is contained in:
commit
e00013520c
@ -87,7 +87,7 @@ namespace HotelDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
var roomLunches = context.RoomLunches.Where(rec => rec.RoomId == model.Id).ToList();
|
var roomLunches = context.RoomLunches.Where(rec => rec.RoomId == model.Id).ToList();
|
||||||
|
|
||||||
if (roomLunches != null)
|
if (roomLunches != null && roomLunches.Count > 0)
|
||||||
{
|
{
|
||||||
context.RoomLunches.RemoveRange(roomLunches.Where(rec => !model.RoomLunches.ContainsKey(rec.LunchId)));
|
context.RoomLunches.RemoveRange(roomLunches.Where(rec => !model.RoomLunches.ContainsKey(rec.LunchId)));
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
@ -101,12 +101,12 @@ namespace HotelDataBaseImplement.Models
|
|||||||
|
|
||||||
var room = context.Rooms.First(x => x.Id == Id);
|
var room = context.Rooms.First(x => x.Id == Id);
|
||||||
|
|
||||||
foreach (var cm in model.RoomLunches)
|
foreach (var lunch in model.RoomLunches)
|
||||||
{
|
{
|
||||||
context.RoomLunches.Add(new RoomLunch
|
context.RoomLunches.Add(new RoomLunch
|
||||||
{
|
{
|
||||||
Room = room,
|
Room = room,
|
||||||
Lunch = context.Lunches.First(x => x.Id == cm.Key)
|
Lunch = context.Lunches.First(x => x.Id == lunch.Key)
|
||||||
});
|
});
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user