This commit is contained in:
MaD 2024-05-02 17:25:14 +04:00
parent 4d7b8f5199
commit 266e6aa1ac
2 changed files with 13 additions and 13 deletions

View File

@ -19,7 +19,7 @@ namespace GiftShopDatabaseImplement.Implements
}
context.Orders.Remove(element);
context.SaveChanges();
return AcessDressesStorage(element.GetViewModel, context);
return AcessGiftsStorage(element.GetViewModel, context);
}
@ -30,7 +30,7 @@ namespace GiftShopDatabaseImplement.Implements
return null;
}
using var context = new GiftShopDatabase();
return AcessDressesStorage(context.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel, context);
return AcessGiftsStorage(context.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel, context);
}
public List<OrderViewModel?> GetFilteredList(OrderSearchModel model)
@ -40,13 +40,13 @@ namespace GiftShopDatabaseImplement.Implements
return new();
}
using var context = new GiftShopDatabase();
return context.Orders.Where(x => x.Id == model.Id).Select(x => AcessDressesStorage(x.GetViewModel, context)).ToList();
return context.Orders.Where(x => x.Id == model.Id).Select(x => AcessGiftsStorage(x.GetViewModel, context)).ToList();
}
public List<OrderViewModel?> GetFullList()
{
using var context = new GiftShopDatabase();
return context.Orders.Select(x => AcessDressesStorage(x.GetViewModel, context)).ToList();
return context.Orders.Select(x => AcessGiftsStorage(x.GetViewModel, context)).ToList();
}
@ -60,7 +60,7 @@ namespace GiftShopDatabaseImplement.Implements
using var context = new GiftShopDatabase();
context.Orders.Add(order);
context.SaveChanges();
return AcessDressesStorage(order.GetViewModel, context);
return AcessGiftsStorage(order.GetViewModel, context);
}
@ -76,22 +76,22 @@ namespace GiftShopDatabaseImplement.Implements
}
order.Update(model);
context.SaveChanges();
return AcessDressesStorage(order.GetViewModel, context);
return AcessGiftsStorage(order.GetViewModel, context);
}
public static OrderViewModel? AcessDressesStorage(OrderViewModel? model, GiftShopDatabase context)
public static OrderViewModel? AcessGiftsStorage(OrderViewModel? model, GiftShopDatabase context)
{
if (model == null)
{
return null;
}
var dress = context.Gifts.FirstOrDefault(x => x.Id == model.GiftId);
if (dress == null)
var gifts = context.Gifts.FirstOrDefault(x => x.Id == model.GiftId);
if (gifts == null)
{
return null;
}
model.GiftName = dress.GiftName;
model.GiftName = gifts.GiftName;
return model;
}

View File

@ -45,14 +45,14 @@ namespace GiftShopFileImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
return source.Orders.Where(x => x.Id == model.Id)
.Select(x => AcessDressesStorage(x.GetViewModel))
.Select(x => AcessGiftsStorage(x.GetViewModel))
.ToList();
}
public List<OrderViewModel> GetFullList()
{
return source.Orders.Select(x => AcessDressesStorage(x.GetViewModel)).ToList();
return source.Orders.Select(x => AcessGiftsStorage(x.GetViewModel)).ToList();
}
@ -88,7 +88,7 @@ namespace GiftShopFileImplement.Implements
return order.GetViewModel;
}
public OrderViewModel AcessDressesStorage(OrderViewModel model)
public OrderViewModel AcessGiftsStorage(OrderViewModel model)
{
var component = source.Gifts.FirstOrDefault(x => x.Id == model.GiftId);
model.GiftName = component.GiftName;