исправление бага с сохранением заказа
добавлено отображение SushiName в OrderViewModel
This commit is contained in:
parent
f5603aee2e
commit
72aa20a1b3
@ -15,7 +15,7 @@ namespace SushiBarFileImplement.Implements
|
||||
}
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
return source.Orders.Select(x => x.GetViewModel).ToList();
|
||||
return source.Orders.Select(x => AttachSushiName(x.GetViewModel)).ToList();
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
@ -25,7 +25,7 @@ namespace SushiBarFileImplement.Implements
|
||||
}
|
||||
return source.Orders.Where(x =>
|
||||
x.Id == model.Id).Select(x =>
|
||||
x.GetViewModel).ToList();
|
||||
AttachSushiName(x.GetViewModel)).ToList();
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
@ -33,8 +33,8 @@ namespace SushiBarFileImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Orders.FirstOrDefault(x =>
|
||||
(x.Id == model.Id))?.GetViewModel;
|
||||
return AttachSushiName(source.Orders.FirstOrDefault(x =>
|
||||
(x.Id == model.Id))?.GetViewModel);
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
@ -46,7 +46,7 @@ namespace SushiBarFileImplement.Implements
|
||||
}
|
||||
source.Orders.Add(newOrder);
|
||||
source.SaveOrders();
|
||||
return newOrder.GetViewModel;
|
||||
return AttachSushiName(newOrder.GetViewModel);
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
@ -57,7 +57,7 @@ namespace SushiBarFileImplement.Implements
|
||||
}
|
||||
order.Update(model);
|
||||
source.SaveOrders();
|
||||
return order.GetViewModel;
|
||||
return AttachSushiName(order.GetViewModel);
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
@ -66,9 +66,15 @@ namespace SushiBarFileImplement.Implements
|
||||
{
|
||||
source.Orders.Remove(element);
|
||||
source.SaveOrders();
|
||||
return element.GetViewModel;
|
||||
return AttachSushiName(element.GetViewModel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private OrderViewModel AttachSushiName(OrderViewModel model)
|
||||
{
|
||||
if (model == null) { return null; }
|
||||
model.SushiName = source.Sushis.First(x => x.Id == model.SushiId).SushiName;
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ namespace SushiBarFileImplement.Models
|
||||
}
|
||||
return new Order()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("id")!.Value),
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
SushiId = Convert.ToInt32(element.Element("SushiId")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
|
Loading…
Reference in New Issue
Block a user