edit orderstorage list 5 lab

This commit is contained in:
revengel66 2024-06-21 15:53:01 +04:00
parent 1d5fe9188e
commit f3d5e963c0

View File

@ -35,7 +35,7 @@ namespace PizzeriaListImplement.Implements
}
foreach (var order in _source.Orders)
{
if ((model.Id.HasValue && order.Id == model.Id))
if (model.Id.HasValue && order.Id == model.Id)
{
return AddPizzaName(order.GetViewModel);
}
@ -46,31 +46,60 @@ namespace PizzeriaListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (!model.Id.HasValue && !model.DateFrom.HasValue)
{
return result;
}
if (model.DateFrom.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
{
result.Add(AddPizzaName(order.GetViewModel));
result.Add(GetViewModel(order));
}
}
return result;
}
else if (model.ClientId.HasValue && !model.Id.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.ClientId == model.ClientId)
{
result.Add(GetViewModel(order));
}
}
}
else if (model.Id.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
result.Add(AddPizzaName(order.GetViewModel));
result.Add(GetViewModel(order));
}
}
}
return result;
}
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var package in _source.Pizzas)
{
if (package.Id == order.PizzaId)
{
viewModel.PizzaName = package.PizzaName;
break;
}
}
foreach (var client in _source.Clients)
{
if (client.Id == order.ClientId)
{
viewModel.ClientFIO = client.ClientFIO;
break;
}
}
return viewModel;
}
public List<OrderViewModel> GetFullList()
{
var result = new List<OrderViewModel>();