ЛР2
This commit is contained in:
parent
58f59670cd
commit
a8888dd285
@ -16,7 +16,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
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)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
@ -25,7 +25,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
{
|
{
|
||||||
return new();
|
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)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
@ -41,7 +41,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
private OrderViewModel GetViewModel(Order order)
|
private OrderViewModel GetViewModel(Order order)
|
||||||
{
|
{
|
||||||
var viewModel = order.GetViewModel;
|
var viewModel = order.GetViewModel;
|
||||||
foreach (var sushi in _source.ListSushi)
|
foreach (var sushi in source.ListSushi)
|
||||||
{
|
{
|
||||||
if (sushi.Id == order.SushiId)
|
if (sushi.Id == order.SushiId)
|
||||||
{
|
{
|
||||||
@ -61,7 +61,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
}
|
}
|
||||||
source.Orders.Add(newOrder);
|
source.Orders.Add(newOrder);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return newOrder.GetViewModel;
|
return GetViewModel(newOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
@ -73,7 +73,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
}
|
}
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return order.GetViewModel;
|
return GetViewModel(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
@ -83,7 +83,7 @@ namespace SushiBarFileImplement.Implements
|
|||||||
{
|
{
|
||||||
source.Orders.Remove(element);
|
source.Orders.Remove(element);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return element.GetViewModel;
|
return GetViewModel(element);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -39,16 +39,23 @@ namespace SushiBarFileImplement.Models
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Order()
|
var order = new Order()
|
||||||
{
|
{
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
SushiId = Convert.ToInt32(element.Element("SushiId")!.Value),
|
SushiId = Convert.ToInt32(element.Element("SushiId")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null),
|
||||||
DateImplement = Convert.ToDateTime(element.Element("DateImplement")!.Value)
|
|
||||||
};
|
};
|
||||||
|
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)
|
public void Update(OrderBindingModel? model)
|
||||||
|
Loading…
Reference in New Issue
Block a user