order + client (list)

This commit is contained in:
VictoriaPresnyakova 2023-04-01 20:54:27 +04:00
parent 6716b74d72
commit dc2492a0e1
2 changed files with 28 additions and 9 deletions

View File

@ -51,15 +51,34 @@ namespace JewelryStoreListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
if (!model.DateFrom.HasValue || !model.DateTo.HasValue) if (model.DateFrom.HasValue)
{ {
return result; foreach (var order in _source.Orders)
}
foreach (var order in _source.Orders)
{
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
{ {
result.Add(order.GetViewModel); if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
{
result.Add(order.GetViewModel);
}
}
}
else if (model.ClientId.HasValue && !model.Id.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.ClientId == model.ClientId)
{
result.Add(order.GetViewModel);
}
}
}
else if (model.Id.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
result.Add(order.GetViewModel);
}
} }
} }
return result; return result;

View File

@ -15,8 +15,6 @@ namespace JewelryStoreListImplement.Models
public int JewelId { get; private set; } public int JewelId { get; private set; }
public string JewelName { get; private set; } public string JewelName { get; private set; }
public int ClientId { get; private set; } public int ClientId { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
@ -38,6 +36,7 @@ namespace JewelryStoreListImplement.Models
{ {
Id = model.Id, Id = model.Id,
JewelId = model.JewelId, JewelId = model.JewelId,
ClientId = model.ClientId,
JewelName = model.JewelName, JewelName = model.JewelName,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
@ -64,6 +63,7 @@ namespace JewelryStoreListImplement.Models
{ {
Id = Id, Id = Id,
JewelId = JewelId, JewelId = JewelId,
ClientId = ClientId,
JewelName = JewelName, JewelName = JewelName,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,