последний (надеюсь) штрих

This commit is contained in:
ujijrujijr 2024-05-01 17:26:50 +04:00
parent 757f7921e0
commit acee749f24

View File

@ -21,14 +21,7 @@ namespace ComputerShopDatabaseImplement.Implements
public List<OrderViewModel> GetFullList()
{
using var context = new ComputerShopDatabase();
return context.Orders
.Include(x => x.Shipments)
.ThenInclude(x => x.Shipment)
.Include(x => x.Requests)
.ThenInclude(x => x.Request)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
return context.Orders.Select(x => x.GetViewModel).ToList();
}
//Учитывается id пользователя (везде получение списка только тех записей, что создал сам пользователь)
@ -40,11 +33,6 @@ namespace ComputerShopDatabaseImplement.Implements
{
return context.Orders
.Where(x => (x.UserId == model.UserId) && (x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo))
.Include(x => x.Shipments)
.ThenInclude(x => x.Shipment)
.Include(x => x.Requests)
.ThenInclude(x => x.Request)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
@ -53,22 +41,12 @@ namespace ComputerShopDatabaseImplement.Implements
{
return context.Orders
.Where(x => (x.UserId == model.UserId) && (x.Status == model.Status))
.Include(x => x.Shipments)
.ThenInclude(x => x.Shipment)
.Include(x => x.Requests)
.ThenInclude(x => x.Request)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
//возвращение просто всех заказов пользователя (замена GetFullList)
return context.Orders
.Where(x => x.UserId == model.UserId)
.Include(x => x.Shipments)
.ThenInclude(x => x.Shipment)
.Include(x => x.Requests)
.ThenInclude(x => x.Request)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
@ -126,12 +104,7 @@ namespace ComputerShopDatabaseImplement.Implements
return null;
}
using var context = new ComputerShopDatabase();
return context.Orders
.Include(x => x.Shipments)
.ThenInclude(x => x.Shipment)
.Include(x => x.Requests)
.ThenInclude(x => x.Request)
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
return context.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public OrderViewModel? Insert(OrderBindingModel model)