izmenenia
This commit is contained in:
parent
4def3caeeb
commit
599fb9e3fd
@ -20,11 +20,16 @@ namespace FishFactoryFileImplement.Implements
|
|||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
return source.Orders.Select(x => AcessDressesStorage(x.GetViewModel)).ToList();
|
return source.Orders.Select(x => GetViewModel(x)).ToList();
|
||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
return source.Orders.Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo).Select(x => AcessDressesStorage(x.GetViewModel)).ToList();
|
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
return source.Orders.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo || x.ClientId == model.ClientId).Select(x => GetViewModel(x)).ToList();
|
||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
@ -68,11 +73,20 @@ namespace FishFactoryFileImplement.Implements
|
|||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return component.GetViewModel;
|
return component.GetViewModel;
|
||||||
}
|
}
|
||||||
public OrderViewModel AcessDressesStorage(OrderViewModel model)
|
private OrderViewModel GetViewModel(Order order)
|
||||||
{
|
{
|
||||||
var component = source.Canneds.FirstOrDefault(x => x.Id == model.CannedId);
|
var viewModel = order.GetViewModel;
|
||||||
model.CannedName = component.CannedName;
|
var canned = source.Canneds.FirstOrDefault(x => x.Id == order.CannedId);
|
||||||
return model;
|
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
||||||
|
if (canned != null)
|
||||||
|
{
|
||||||
|
viewModel.CannedName = canned.CannedName;
|
||||||
|
}
|
||||||
|
if (client != null)
|
||||||
|
{
|
||||||
|
viewModel.ClientFIO = client.ClientFIO;
|
||||||
|
}
|
||||||
|
return viewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace FishFactoryListImplement.Implements
|
|||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
result.Add(AccessCannedStorage(order.GetViewModel));
|
result.Add(GetViewModel(order));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -31,10 +31,34 @@ namespace FishFactoryListImplement.Implements
|
|||||||
model)
|
model)
|
||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
if (model.Id.HasValue)
|
if (!model.Id.HasValue)
|
||||||
return _source.Orders.Where(x => x.Id == model.Id).Select(x => AccessCannedStorage(x.GetViewModel)).ToList();
|
{
|
||||||
else
|
return result;
|
||||||
return _source.Orders.Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo).Select(x => AccessCannedStorage(x.GetViewModel)).ToList();
|
}
|
||||||
|
|
||||||
|
if (model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.ClientId == model.ClientId)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
@ -94,18 +118,30 @@ namespace FishFactoryListImplement.Implements
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
private OrderViewModel GetViewModel(Order order)
|
||||||
public OrderViewModel AccessCannedStorage(OrderViewModel model)
|
|
||||||
{
|
{
|
||||||
|
var viewModel = order.GetViewModel;
|
||||||
|
|
||||||
foreach (var canned in _source.Canneds)
|
foreach (var canned in _source.Canneds)
|
||||||
{
|
{
|
||||||
if (canned.Id == model.CannedId)
|
if (canned.Id == order.CannedId)
|
||||||
{
|
{
|
||||||
model.CannedName = canned.CannedName;
|
viewModel.CannedName = canned.CannedName;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return model;
|
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Id == order.ClientId)
|
||||||
|
{
|
||||||
|
viewModel.ClientFIO = client.ClientFIO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return viewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user