Lisov N.A LabWork7 #7

Closed
1yuee wants to merge 5 commits from LabWork07 into LabWork06
2 changed files with 55 additions and 4 deletions
Showing only changes of commit 67b9f9ecec - Show all commits

View File

@ -27,11 +27,24 @@ namespace DressAtelierFileImplement.Implements
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.ID.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
if (!model.ID.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientID.HasValue && !model.Status.HasValue)
{
return new();
}
return _source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => ReceiveDressName(x)).ToList();
if (model.ClientID.HasValue)
{
return _source.Orders.Where(x => x.ClientID == model.ClientID).Select(x => ReceiveDressName(x)).ToList();
}
if (model.ID.HasValue)
{
return _source.Orders.Where(x => x.ID == model.ID).Select(x => ReceiveDressName(x)).ToList();
}
if (model.DateFrom.HasValue && model.DateTo.HasValue)
{
return _source.Orders.Where(x => model.DateFrom >= x.DateCreate && model.DateTo <= x.DateCreate).Select(x => ReceiveDressName(x)).ToList();
}
return _source.Orders.Where(x => x.Status.Equals(model.Status)).ToList().Select(x => ReceiveDressName(x)).ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)

View File

@ -32,10 +32,37 @@ namespace DressAtelierListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (!model.ID.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
if (!model.ID.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientID.HasValue && !model.Status.HasValue)
{
return result;
}
if (model.ClientID.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.ClientID == model.ClientID)
{
result.Add(ReceiveDressName(order.GetViewModel));
}
}
return result;
}
if (model.ID.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.ID == model.ID)
{
result.Add(ReceiveDressName(order.GetViewModel));
}
}
return result;
}
if (model.DateFrom.HasValue && model.DateTo.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
@ -46,6 +73,17 @@ namespace DressAtelierListImplement.Implements
return result;
}
foreach (var order in _source.Orders)
{
if (order.Status == model.Status)
{
result.Add(ReceiveDressName(order.GetViewModel));
}
}
return result;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.ID.HasValue)