This commit is contained in:
dasha 2023-02-12 15:29:29 +04:00
parent 58f59670cd
commit a8888dd285
2 changed files with 18 additions and 11 deletions

View File

@ -16,7 +16,7 @@ namespace SushiBarFileImplement.Implements
public List<OrderViewModel> GetFullList()
{
return source.Orders.Select(x => x.GetViewModel).ToList();
return source.Orders.Select(x => GetViewModel(x)).ToList();
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
@ -25,7 +25,7 @@ namespace SushiBarFileImplement.Implements
{
return new();
}
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => x.GetViewModel).ToList();
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
@ -41,7 +41,7 @@ namespace SushiBarFileImplement.Implements
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var sushi in _source.ListSushi)
foreach (var sushi in source.ListSushi)
{
if (sushi.Id == order.SushiId)
{
@ -61,7 +61,7 @@ namespace SushiBarFileImplement.Implements
}
source.Orders.Add(newOrder);
source.SaveOrders();
return newOrder.GetViewModel;
return GetViewModel(newOrder);
}
public OrderViewModel? Update(OrderBindingModel model)
@ -73,7 +73,7 @@ namespace SushiBarFileImplement.Implements
}
order.Update(model);
source.SaveOrders();
return order.GetViewModel;
return GetViewModel(order);
}
public OrderViewModel? Delete(OrderBindingModel model)
@ -83,7 +83,7 @@ namespace SushiBarFileImplement.Implements
{
source.Orders.Remove(element);
source.SaveOrders();
return element.GetViewModel;
return GetViewModel(element);
}
return null;
}

View File

@ -39,16 +39,23 @@ namespace SushiBarFileImplement.Models
{
return null;
}
return new Order()
var order = new Order()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
SushiId = Convert.ToInt32(element.Element("SushiId")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
DateImplement = Convert.ToDateTime(element.Element("DateImplement")!.Value)
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null),
};
DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl);
order.DateImplement = dateImpl;
if (!Enum.TryParse(element.Element("Status")!.Value, out OrderStatus status))
{
return null;
}
order.Status = status;
return order;
}
public void Update(OrderBindingModel? model)