From 7868ce808fe99358a61e7a0c2914a124a6e9d818 Mon Sep 17 00:00:00 2001 From: tellsense Date: Fri, 3 May 2024 23:34:57 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D0=B6=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=B7=D0=B0=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D1=8B=20=D0=B2=20web=20(=D1=81=D0=B8=D0=B6=D1=83?= =?UTF-8?q?=204=20=D1=87=D0=B0=D1=81=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/SushiBarClientApp/Program.cs | 20 ++++++++++++++----- .../SushiBarDatabaseImplement/OrderStorage.cs | 20 ++++++++++++------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/SushiBar/SushiBarClientApp/Program.cs b/SushiBar/SushiBarClientApp/Program.cs index 8a8b56e..0dfe7a4 100644 --- a/SushiBar/SushiBarClientApp/Program.cs +++ b/SushiBar/SushiBarClientApp/Program.cs @@ -1,21 +1,31 @@ using SushiBarClientApp; var builder = WebApplication.CreateBuilder(args); + // Add services to the container. builder.Services.AddControllersWithViews(); + var app = builder.Build(); + APIClient.Connect(builder.Configuration); + // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { - app.UseExceptionHandler("/Home/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); + app.UseExceptionHandler("/Home/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); } + app.UseHttpsRedirection(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthorization(); + app.MapControllerRoute( - name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); + app.Run(); \ No newline at end of file diff --git a/SushiBar/SushiBarDatabaseImplement/OrderStorage.cs b/SushiBar/SushiBarDatabaseImplement/OrderStorage.cs index 1a9feac..cf0bc74 100644 --- a/SushiBar/SushiBarDatabaseImplement/OrderStorage.cs +++ b/SushiBar/SushiBarDatabaseImplement/OrderStorage.cs @@ -17,13 +17,19 @@ namespace SushiBarDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - using var context = new SushiBarDatabase(); - if (model.DateFrom.HasValue) - { - return context.Orders.Include(x => x.Sushi).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList(); - } - return context.Orders.Include(x => x.Sushi).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList(); - } + { + using var context = new SushiBarDatabase(); + if (model.DateFrom.HasValue) + { + return context.Orders.Include(x => x.Sushi).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList(); + } + if (model.ClientId.HasValue) + { + return context.Orders.Include(x => x.Sushi).Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList(); + } + return context.Orders.Include(x => x.Sushi).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList(); + } + } public OrderViewModel? GetElement(OrderSearchModel model) {