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() {