diff --git a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs index d45f3b6..c366446 100644 --- a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs @@ -122,6 +122,10 @@ namespace FoodOrdersBusinessLogic.BusinessLogics _logger.LogWarning("Change status operation failed"); return false; } + if (viewModel.ImplementerId.HasValue) + { + model.ImplementerId = viewModel.ImplementerId; + } model.Status = newStatus; if (model.Status == OrderStatus.Готов) { diff --git a/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs b/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs index 2c4e7eb..36edc60 100644 --- a/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs +++ b/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs @@ -37,17 +37,17 @@ namespace FoodOrdersDatabaseImplement.Implements .Select(x => x.GetViewModel) .ToList(); } - else if (model.DateFrom.HasValue && model.DateTo.HasValue) + if (model.DateFrom.HasValue && model.DateTo.HasValue) { return context.Orders - .Include(x => x.Dish) - .Include(x => x.Client) - .Include(x => x.Implementer) - .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) - .Select(x => x.GetViewModel) - .ToList(); + .Include(x => x.Dish) + .Include(x => x.Client) + .Include(x => x.Implementer) + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); } - else if (model.Status != null) + if (model.Status != null) { return context.Orders .Include(x => x.Dish) @@ -55,7 +55,7 @@ namespace FoodOrdersDatabaseImplement.Implements .Include(x => x.Implementer) .Where(x => model.Status == x.Status) .Select(x => x.GetViewModel) - .ToList(); ; + .ToList(); } return context.Orders .Include(x => x.Dish) diff --git a/FoodOrders/FoodOrdersFileImplement/Implements/OrderStorage.cs b/FoodOrders/FoodOrdersFileImplement/Implements/OrderStorage.cs index ed8b9c5..0a1bf1e 100644 --- a/FoodOrders/FoodOrdersFileImplement/Implements/OrderStorage.cs +++ b/FoodOrders/FoodOrdersFileImplement/Implements/OrderStorage.cs @@ -21,6 +21,10 @@ namespace FoodOrdersFileImplement.Implements } public List GetFilteredList(OrderSearchModel model) { + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.ClientId.HasValue && !model.Status.HasValue) + { + return new(); + } if (model.ClientId.HasValue) { return _source.Orders @@ -28,14 +32,24 @@ namespace FoodOrdersFileImplement.Implements .Select(x => GetViewModel(x)) .ToList(); } - if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) + if (model.DateFrom.HasValue && model.DateTo.HasValue) { return _source.Orders .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) .Select(x => GetViewModel(x)) .ToList(); } - return _source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList(); + if (model.Status != null) + { + return _source.Orders + .Where(x => model.Status == x.Status) + .Select(x => GetViewModel(x)) + .ToList(); + } + return _source.Orders + .Where(x => x.Id == model.Id) + .Select(x => GetViewModel(x)) + .ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) diff --git a/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs index 539844c..f85c05f 100644 --- a/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs +++ b/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs @@ -30,6 +30,10 @@ namespace FoodOrdersListImplement.Implements public List GetFilteredList(OrderSearchModel model) { var result = new List(); + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.ClientId.HasValue && !model.Status.HasValue) + { + return new(); + } if (model.ClientId.HasValue) { foreach (var order in _source.Orders) @@ -41,7 +45,7 @@ namespace FoodOrdersListImplement.Implements } return result; } - if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) + if (model.DateFrom.HasValue && model.DateTo.HasValue) { foreach (var order in _source.Orders) { @@ -52,6 +56,17 @@ namespace FoodOrdersListImplement.Implements } return result; } + if (model.Status != null) + { + foreach (var order in _source.Orders) + { + if (model.Status == order.Status) + { + result.Add(GetViewModel(order)); + } + } + return result; + } foreach (var order in _source.Orders) { if (order.Id == model.Id)