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

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

View File

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

View File

@ -9,7 +9,7 @@ namespace SushiBarDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) 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); base.OnConfiguring(optionsBuilder);
} }