This commit is contained in:
Павел Сорокин 2023-02-28 12:31:50 +04:00
parent c27f6c9662
commit 235873dc7a
2 changed files with 7 additions and 14 deletions

View File

@ -1,4 +1,5 @@
using ShipyardContracts.BindingModels;
using Microsoft.EntityFrameworkCore;
using ShipyardContracts.BindingModels;
using ShipyardContracts.SearchModels;
using ShipyardContracts.StoragesContracts;
using ShipyardContracts.ViewModels;
@ -65,17 +66,8 @@ namespace ShipyardDataBaseImplement.Implements
{
using var context = new ShipyardDataBase();
return context.Orders
.Select(x => new OrderViewModel
{
Id = x.Id,
ShipId = x.ShipId,
Count = x.Count,
Sum = x.Sum,
Status = x.Status,
DateCreate = x.DateCreate,
DateImplement = x.DateImplement,
ShipName = x.Ship.ShipName
})
.Include(x => x.Ship)
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -27,7 +27,7 @@ namespace ShipyardDataBaseImplement.Models
public DateTime? DateImplement { get; set; }
public int Id { get; set; }
public Ship? Ship { get; set; }
public virtual Ship Ship { get; set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
@ -64,7 +64,8 @@ namespace ShipyardDataBaseImplement.Models
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
DateImplement = DateImplement,
ShipName=Ship.ShipName
};
}
}