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