Незагруженное исправление.

This commit is contained in:
Programmist73 2023-03-23 23:46:10 +04:00
parent 867b5507db
commit 6b5b1ec34d

View File

@ -55,38 +55,19 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
using var context = new BlacksmithWorkshopDatabase();
return context.Orders
.Include(x => x.Manufacture)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
private static OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
using var context = new BlacksmithWorkshopDatabase();
var element = context.Manufactures
.FirstOrDefault(x => x.Id == order.ManufactureId);
viewModel.ManufactureName = element.ManufactureName;
return viewModel;
}
public List<OrderViewModel> GetFullList()
{
using var context = new BlacksmithWorkshopDatabase();
return context.Orders
.Select(x => new OrderViewModel
{
Id = x.Id,
ManufactureId = x.ManufactureId,
Count = x.Count,
Sum = x.Sum,
Status = x.Status,
DateCreate = x.DateCreate,
DateImplement = x.DateImplement,
ManufactureName = x.Manufacture.ManufactureName
})
.Include(x => x.Manufacture)
.Select(x => x.GetViewModel)
.ToList();
}
@ -103,7 +84,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
context.Orders.Add(newOrder);
context.SaveChanges();
return newOrder.GetViewModel;
return context.Orders.Include(x => x.Manufacture)
.FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)