PIbd-21. Raspaev N. I. HardLabWork05 #13

Closed
Nikolay-Raspaev wants to merge 23 commits from HardLabWork05 into HardLabWork04
3 changed files with 11 additions and 2 deletions
Showing only changes of commit 2d65463f24 - Show all commits

View File

@ -1,10 +1,12 @@
using FoodOrdersClientApp;
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())
{

View File

@ -14,6 +14,7 @@ namespace FoodOrdersDatabaseImplement.Implements
using var context = new FoodOrdersDatabase();
return context.Orders
.Include(x => x.Dish)
.Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
}
@ -24,6 +25,7 @@ namespace FoodOrdersDatabaseImplement.Implements
if (model.ClientId.HasValue)
{
return context.Orders
.Include(x => x.Dish)
.Include(x => x.Client)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
@ -33,12 +35,14 @@ namespace FoodOrdersDatabaseImplement.Implements
{
return context.Orders
.Include(x => x.Dish)
.Include(x => x.Client)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Include(x => x.Dish)
.Include(x => x.Client)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
@ -53,6 +57,7 @@ namespace FoodOrdersDatabaseImplement.Implements
using var context = new FoodOrdersDatabase();
return context.Orders
.Include(x => x.Dish)
.Include(x => x.Client)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
@ -69,6 +74,7 @@ namespace FoodOrdersDatabaseImplement.Implements
context.SaveChanges();
return context.Orders
.Include(x => x.Dish)
.Include(x => x.Client)
.FirstOrDefault(x => x.Id == newOrder.Id)
?.GetViewModel;
}
@ -85,6 +91,7 @@ namespace FoodOrdersDatabaseImplement.Implements
context.SaveChanges();
return context.Orders
.Include(x => x.Dish)
.Include(x => x.Client)
.FirstOrDefault(x => x.Id == order.Id)
?.GetViewModel;
}

View File

@ -16,7 +16,7 @@ builder.Services.AddTransient<IDishStorage, DishStorage>();
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddTransient<IDishStorage, DishStorage>();
builder.Services.AddTransient<IDishLogic, DishLogic>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle