edit orderstorage list 5 lab
This commit is contained in:
parent
1d5fe9188e
commit
f3d5e963c0
@ -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;
|
||||
}
|
||||
foreach (var order in _source.Orders)
|
||||
else if (model.ClientId.HasValue && !model.Id.HasValue)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(AddPizzaName(order.GetViewModel));
|
||||
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(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>();
|
||||
|
Loading…
Reference in New Issue
Block a user