From dc2492a0e1a967fddcab544a1b0afbe74e8c230f Mon Sep 17 00:00:00 2001 From: VictoriaPresnyakova Date: Sat, 1 Apr 2023 20:54:27 +0400 Subject: [PATCH] order + client (list) --- .../Implements/OrderStorage.cs | 33 +++++++++++++++---- JewelryStoreListImplement/Models/Order.cs | 4 +-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/JewelryStoreListImplement/Implements/OrderStorage.cs b/JewelryStoreListImplement/Implements/OrderStorage.cs index dee309f..f065ccb 100644 --- a/JewelryStoreListImplement/Implements/OrderStorage.cs +++ b/JewelryStoreListImplement/Implements/OrderStorage.cs @@ -51,15 +51,34 @@ namespace JewelryStoreListImplement.Implements public List GetFilteredList(OrderSearchModel model) { var result = new List(); - if (!model.DateFrom.HasValue || !model.DateTo.HasValue) + if (model.DateFrom.HasValue) { - return result; - } - foreach (var order in _source.Orders) - { - if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) + foreach (var order in _source.Orders) { - 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; diff --git a/JewelryStoreListImplement/Models/Order.cs b/JewelryStoreListImplement/Models/Order.cs index 3fd4119..23c1fbb 100644 --- a/JewelryStoreListImplement/Models/Order.cs +++ b/JewelryStoreListImplement/Models/Order.cs @@ -15,8 +15,6 @@ namespace JewelryStoreListImplement.Models public int JewelId { get; private set; } public string JewelName { get; private set; } public int ClientId { get; private set; } - - public int Count { get; private set; } public double Sum { get; private set; } @@ -38,6 +36,7 @@ namespace JewelryStoreListImplement.Models { Id = model.Id, JewelId = model.JewelId, + ClientId = model.ClientId, JewelName = model.JewelName, Count = model.Count, Sum = model.Sum, @@ -64,6 +63,7 @@ namespace JewelryStoreListImplement.Models { Id = Id, JewelId = JewelId, + ClientId = ClientId, JewelName = JewelName, Count = Count, Sum = Sum,