Может быть так будет лучше

This commit is contained in:
dasha 2023-02-28 12:38:33 +04:00
parent 9450ae2f6f
commit 1a41ad5ce3
3 changed files with 8 additions and 15 deletions

View File

@ -1,4 +1,5 @@
using SushiBarContracts.BindingModels;
using Microsoft.EntityFrameworkCore;
using SushiBarContracts.BindingModels;
using SushiBarContracts.SearchModels;
using SushiBarContracts.StoragesContracts;
using SushiBarContracts.ViewModels;
@ -49,18 +50,9 @@ namespace SushiBarDatabaseImplement.Implements
{
using var context = new SushiBarDatabase();
return context.Orders
.Select(x => new OrderViewModel
{
Id = x.Id,
SushiId = x.SushiId,
Count = x.Count,
Sum = x.Sum,
Status = x.Status,
DateCreate = x.DateCreate,
DateImplement = x.DateImplement,
SushiName = x.Sushi.SushiName
})
.ToList();
.Include(x => x.Sushi)
.Select(x => x.GetViewModel)
.ToList();
}
public OrderViewModel? Insert(OrderBindingModel model)

View File

@ -20,7 +20,7 @@ namespace SushiBarDatabaseImplement.Models
public DateTime DateCreate { get; set; }
public DateTime? DateImplement { get; set; }
public int Id { get; set; }
public virtual Sushi Sushi { get; set; }
public Sushi Sushi { get; set; }
public static Order? Create(OrderBindingModel? model)
{
@ -59,6 +59,7 @@ namespace SushiBarDatabaseImplement.Models
DateImplement = DateImplement,
Id = Id,
Status = Status,
SushiName = Sushi.SushiName,
};
}
}

View File

@ -9,7 +9,7 @@ namespace SushiBarDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D8KMQQU\SQLEXPRESS;Initial Catalog=SushiBarDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-JC256C6\SQLEXPRESS;Initial Catalog=SushiBarDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}