убрал (частично закомментил) ошибки для миграции. ДО МИГРАЦИИ
This commit is contained in:
parent
cb2210f479
commit
efe2bb327b
@ -24,9 +24,9 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new ComputerShopDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.ShipmentOrders)
|
||||
.Include(x => x.Shipments)
|
||||
.ThenInclude(x => x.Shipment)
|
||||
.Include(x => x.RequestOrders)
|
||||
.Include(x => x.Requests)
|
||||
.ThenInclude(x => x.Request)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -40,9 +40,9 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
{
|
||||
return context.Orders
|
||||
.Where(x => (x.UserId == model.UserId) && (x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo))
|
||||
.Include(x => x.ShipmentOrders)
|
||||
.Include(x => x.Shipments)
|
||||
.ThenInclude(x => x.Shipment)
|
||||
.Include(x => x.RequestOrders)
|
||||
.Include(x => x.Requests)
|
||||
.ThenInclude(x => x.Request)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -52,9 +52,9 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
{
|
||||
return context.Orders
|
||||
.Where(x => (x.UserId == model.UserId) && (x.Status == model.Status))
|
||||
.Include(x => x.ShipmentOrders)
|
||||
.Include(x => x.Shipments)
|
||||
.ThenInclude(x => x.Shipment)
|
||||
.Include(x => x.RequestOrders)
|
||||
.Include(x => x.Requests)
|
||||
.ThenInclude(x => x.Request)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -63,9 +63,9 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
//возвращение просто всех заказов пользователя (замена GetFullList)
|
||||
return context.Orders
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Include(x => x.ShipmentOrders)
|
||||
.Include(x => x.Shipments)
|
||||
.ThenInclude(x => x.Shipment)
|
||||
.Include(x => x.RequestOrders)
|
||||
.Include(x => x.Requests)
|
||||
.ThenInclude(x => x.Request)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -80,9 +80,9 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
}
|
||||
using var context = new ComputerShopDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.ShipmentOrders)
|
||||
.Include(x => x.Shipments)
|
||||
.ThenInclude(x => x.Shipment)
|
||||
.Include(x => x.RequestOrders)
|
||||
.Include(x => x.Requests)
|
||||
.ThenInclude(x => x.Request)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
@ -14,28 +14,21 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
{
|
||||
public class UserStorage : IUserStorage
|
||||
{
|
||||
//!!!ТУТ МБ РАЗДЕЛИТЬ НА 2 МЕТОДА: исполнителя и поручителя и добавить where
|
||||
public List<UserViewModel> GetFullList(UserRole role)
|
||||
public List<UserViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ComputerShopDatabase();
|
||||
return context.Users.Where(x => x.Role == role).Select(x => x.GetViewModel).ToList();
|
||||
return context.Users.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
//!!!ТУТ МБ РАЗДЕЛИТЬ НА 2 МЕТОДА: исполнителя и поручителя и добавить where
|
||||
//!!!ДОПИСАТЬ
|
||||
//!!!мб не надо, т.к. есть getelement для получения 1 пользователя и получение всех пользователей по роли.
|
||||
//при фильтрации всегда (?) будет либо 1, либо все пользователи роли
|
||||
//Фильтрация пользователей логически нужна только для роли (по остальным параметрам будет 1 или 0 пользователей)
|
||||
public List<UserViewModel> GetFilteredList(UserSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Login))
|
||||
if (model.Role == null || model.Role == UserRole.Неизвестная)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerShopDatabase();
|
||||
if (!string.IsNullOrEmpty(model.Login))
|
||||
{
|
||||
|
||||
}
|
||||
return context.Users.Where(x => x.Role == model.Role).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
//!!!ПРОВЕРИТЬ
|
||||
@ -46,10 +39,18 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new ComputerShopDatabase();
|
||||
return context.Users.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)
|
||||
|| (!string.IsNullOrEmpty(model.Login) && x.Login == model.Login)
|
||||
|| (!string.IsNullOrEmpty(model.Email) && x.Email == model.Email))
|
||||
?.GetViewModel;
|
||||
//Получение по логину (пользователей с таким логином будет 1 или 0)
|
||||
if (!string.IsNullOrEmpty(model.Login))
|
||||
{
|
||||
return context.Users.FirstOrDefault(x => x.Login == model.Login)?.GetViewModel;
|
||||
}
|
||||
//Получение по почте (пользователей с такой почтой будет 1 или 0)
|
||||
else if (!string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return context.Users.FirstOrDefault(x => x.Email == model.Email)?.GetViewModel;
|
||||
}
|
||||
//Получение по id
|
||||
return context.Users.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public UserViewModel? Insert(UserBindingModel model)
|
||||
|
@ -29,16 +29,15 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
|
||||
//!!!мб не нужен
|
||||
public virtual User User { get; set; }
|
||||
|
||||
//!!!ПРОВЕРМТЬ, ЧТО ПАРВИЛЬНЫЕ ВНЕШНИЕ КЛЮЧИ
|
||||
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<RequestOrder> RequestOrders { get; set; } = new();
|
||||
public virtual List<RequestOrder> Requests { get; set; } = new();
|
||||
|
||||
//!!!было ShipmentOrders
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<ShipmentOrder> ShipmentOrders { get; set; } = new();
|
||||
public virtual List<ShipmentOrder> Shipments { get; set; } = new();
|
||||
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
{
|
||||
@ -63,7 +62,6 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
return;
|
||||
}
|
||||
using var context = new ComputerShopDatabase();
|
||||
//!!!МБ НАДО БУДЕТ ОБНОВЛЯТЬ ПОЛЬЗОВАТЕЛЯ, НО ОН ПО СУТИ НЕ ДОЛЖЕН ОБНОВЛЯТЬСЯ ПОСЛЕ СОЗДАНИЯ
|
||||
Status = model.Status;
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
@ -4,17 +4,22 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
||||
//!!!ÇÀÃËÓØÊÀ: ÇÀÊÎÌÌÅÍÒÈË, ×ÒÎÁÛ ÍÎÐÌÀËÜÍÎ ÑÎÇÄÀËÀÑÜ ÌÈÃÐÀÖÈß
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
//builder.Services.AddSwaggerGen(c =>
|
||||
//{
|
||||
// c.SwaggerDoc("v1", new OpenApiInfo { Title = "GarmentFactoryRestApi", Version = "v1" });
|
||||
//});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
//if (app.Environment.IsDevelopment())
|
||||
//{
|
||||
// app.UseSwagger();
|
||||
// app.UseSwaggerUI();
|
||||
//}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user