From 49f7b0b7921690dc46e17f748889e7ae5adc49a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com> Date: Sun, 12 May 2024 17:51:34 +0400 Subject: [PATCH] Full done --- .../Controllers/HomeController.cs | 3 +-- .../SearchModels/OrderSearchModel.cs | 2 +- .../Implements/OrderStorage.cs | 25 +++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/SushiBar/SushiBarClientApp/Controllers/HomeController.cs b/SushiBar/SushiBarClientApp/Controllers/HomeController.cs index d9a1e4a..87d5378 100644 --- a/SushiBar/SushiBarClientApp/Controllers/HomeController.cs +++ b/SushiBar/SushiBarClientApp/Controllers/HomeController.cs @@ -20,8 +20,7 @@ namespace SushiBarClientApp.Controllers { return Redirect("~/Home/Enter"); } - return - View(APIClient.GetRequest>($"api/main/getorders?clientId={APIClient.Client.Id}")); + return View(APIClient.GetRequest>($"api/main/getorders?clientId={APIClient.Client.Id}")); } [HttpGet] public IActionResult Privacy() diff --git a/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs index d8640c1..feaa39a 100644 --- a/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs +++ b/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs @@ -6,7 +6,7 @@ namespace SushiBarContracts.SearchModels public int? Id { get; set; } public DateTime? DateTo { get; set; } public DateTime? DateFrom { get; set; } - public int ClientId { get; set; } + public int? ClientId { get; set; } } } diff --git a/SushiBar/SushiBarDatabaseImplement/Implements/OrderStorage.cs b/SushiBar/SushiBarDatabaseImplement/Implements/OrderStorage.cs index 5de7f1c..f86bca2 100644 --- a/SushiBar/SushiBarDatabaseImplement/Implements/OrderStorage.cs +++ b/SushiBar/SushiBarDatabaseImplement/Implements/OrderStorage.cs @@ -40,11 +40,7 @@ namespace SushiBarDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { using var context = new SushiBarDatabase(); - if (!model.Id.HasValue && (model.DateFrom == null || model.DateTo == null)) - { - return new(); - } - else + if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) { return context.Orders .Include(x => x.Sushi) @@ -53,6 +49,25 @@ namespace SushiBarDatabaseImplement.Implements .Select(x => x.GetViewModel) .ToList(); } + else if (model.Id.HasValue) + { + return context.Orders + .Include(x => x.Sushi) + .Include(x => x.Client) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } + else if (model.ClientId.HasValue) + { + return context.Orders + .Include(x => x.Sushi) + .Include(x => x.Client) + .Where(x => x.ClientId == model.ClientId) + .Select(x => x.GetViewModel) + .ToList(); + } + return new(); } public List GetFullList() {