не отображаются заказы в web (сижу 4 часа)

This commit is contained in:
Андрей Байгулов 2024-05-03 23:34:57 +04:00
parent 11ac5b1fe0
commit 7868ce808f
2 changed files with 28 additions and 12 deletions

View File

@ -1,9 +1,13 @@
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())
{
@ -11,11 +15,17 @@ if (!app.Environment.IsDevelopment())
// 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?}");
app.Run();

View File

@ -16,14 +16,20 @@ namespace SushiBarDatabaseImplement.Implements
}
public List<OrderViewModel> 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();
}
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)
{