diff --git a/SushiBar/SushiBarDatabaseImplement/Implements/OrderStorage.cs b/SushiBar/SushiBarDatabaseImplement/Implements/OrderStorage.cs index ab5eea7..7672d5e 100644 --- a/SushiBar/SushiBarDatabaseImplement/Implements/OrderStorage.cs +++ b/SushiBar/SushiBarDatabaseImplement/Implements/OrderStorage.cs @@ -38,7 +38,7 @@ namespace SushiBarDatabaseImplement.Implements .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; } - if (model.ImplementerId.HasValue && model.OrderStatus.HasValue) + else if (model.ImplementerId.HasValue && model.OrderStatus.HasValue) { return context.Orders .Include(x => x.Sushi) @@ -46,6 +46,14 @@ namespace SushiBarDatabaseImplement.Implements .FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.OrderStatus) ?.GetViewModel; } + else if (model.ImplementerId.HasValue) + { + return context.Orders + .Include(x => x.Sushi) + .Include(x => x.Client).Include(x => x.Implementer) + .FirstOrDefault(x => x.ImplementerId == model.ImplementerId) + ?.GetViewModel; + } return null; } @@ -91,6 +99,7 @@ namespace SushiBarDatabaseImplement.Implements return context.Orders .Include(x => x.Sushi) .Include(x => x.Client) + .Include(x => x.Implementer) .Select(x => x.GetViewModel) .ToList(); } @@ -108,6 +117,7 @@ namespace SushiBarDatabaseImplement.Implements return context.Orders .Include(x => x.Sushi) .Include(x => x.Client) + .Include(x => x.Implementer) .FirstOrDefault(x => x.Id == newOrder.Id) ?.GetViewModel; } @@ -118,6 +128,7 @@ namespace SushiBarDatabaseImplement.Implements var order = context.Orders .Include(x => x.Sushi) .Include(x => x.Client) + .Include(x => x.Implementer) .FirstOrDefault(x => x.Id == model.Id); if (order == null) { diff --git a/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs b/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs index 76ed27c..4718102 100644 --- a/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs +++ b/SushiBar/SushiBarListImplement/Implements/OrderStorage.cs @@ -26,7 +26,7 @@ namespace SushiBarListImplement.Implements { var result = new List(); - if (model.DateFrom.HasValue) + if (model.DateFrom.HasValue && model.DateTo.HasValue) { foreach (var order in _source.Orders) { @@ -46,6 +46,16 @@ namespace SushiBarListImplement.Implements } } } + else if (model.OrderStatus.HasValue) + { + foreach (var order in _source.Orders) + { + if (order.Status == model.OrderStatus) + { + result.Add(GetViewModel(order)); + } + } + } else if (model.Id.HasValue) { foreach (var order in _source.Orders) @@ -92,6 +102,14 @@ namespace SushiBarListImplement.Implements break; } } + foreach (var implementer in _source.Implementers) + { + if (implementer.Id == order.ImplementerId) + { + viewModel.ImplementerFIO = implementer.ImplementerFIO; + break; + } + } return viewModel; } public OrderViewModel? Insert(OrderBindingModel model) diff --git a/SushiBar/SushiBarListImplement/Models/Implementer.cs b/SushiBar/SushiBarListImplement/Models/Implementer.cs index 6d87636..4abc2e2 100644 --- a/SushiBar/SushiBarListImplement/Models/Implementer.cs +++ b/SushiBar/SushiBarListImplement/Models/Implementer.cs @@ -1,11 +1,6 @@ using SushiBarContracts.BindingModels; using SushiBarContracts.ViewModels; using SushiBarDataModels.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SushiBarListImplement.Models { diff --git a/SushiBar/SushiBarListImplement/Models/Order.cs b/SushiBar/SushiBarListImplement/Models/Order.cs index 74d1f03..90710ee 100644 --- a/SushiBar/SushiBarListImplement/Models/Order.cs +++ b/SushiBar/SushiBarListImplement/Models/Order.cs @@ -2,7 +2,6 @@ using SushiBarContracts.ViewModels; using SushiBarDataModels.Enums; using SushiBarDataModels.Models; -using System.Reflection; namespace SushiBarListImplement.Models { @@ -11,6 +10,7 @@ namespace SushiBarListImplement.Models public int Id { get; private set; } public int SushiId { get; private set; } public int ClientId { get; private set; } + public int? ImplementerId { get; private set; } public int Count { get; private set; } public double Sum { get; private set; } public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; @@ -26,6 +26,7 @@ namespace SushiBarListImplement.Models { SushiId = model.SushiId, ClientId = model.ClientId, + ImplementerId = model.ImplementerId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -41,12 +42,14 @@ namespace SushiBarListImplement.Models return; } Status = model.Status; + ImplementerId = model.ImplementerId; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() { SushiId = SushiId, ClientId = ClientId, + ImplementerId = ImplementerId, Count = Count, Sum = Sum, DateCreate = DateCreate, diff --git a/SushiBar/SushiBarRestApi/Controllers/ImplementerController.cs b/SushiBar/SushiBarRestApi/Controllers/ImplementerController.cs index f180fbf..ebf3be2 100644 --- a/SushiBar/SushiBarRestApi/Controllers/ImplementerController.cs +++ b/SushiBar/SushiBarRestApi/Controllers/ImplementerController.cs @@ -3,6 +3,7 @@ using SushiBarContracts.BindingModels; using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.SearchModels; using SushiBarContracts.ViewModels; +using SushiBarDataModels.Enums; namespace SushiBarRestApi.Controllers { @@ -48,7 +49,7 @@ namespace SushiBarRestApi.Controllers { return _order.ReadList(new OrderSearchModel { - //Status = OrderStatus.Принят + OrderStatus = OrderStatus.Принят }); } catch (Exception ex) @@ -65,7 +66,7 @@ namespace SushiBarRestApi.Controllers { return _order.ReadElement(new OrderSearchModel { - //ImplementerId = implementerId + ImplementerId = implementerId }); } catch (Exception ex)