Добавлена возможность получения списка компонент из бд вместе с изделием

This commit is contained in:
Данияр Аглиуллов 2023-02-28 22:19:14 +04:00
parent b18e9a142d
commit f2ca847c6b

View File

@ -4,6 +4,7 @@ using ConfectioneryContracts.StoragesContract;
using ConfectioneryContracts.ViewModels; using ConfectioneryContracts.ViewModels;
using ConfectioneryDatabaseImplement; using ConfectioneryDatabaseImplement;
using ConfectioneryDatabaseImplement.Models; using ConfectioneryDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace ConfectioneryDatabaseImplement.Implements namespace ConfectioneryDatabaseImplement.Implements
{ {
@ -29,7 +30,10 @@ namespace ConfectioneryDatabaseImplement.Implements
return null; return null;
} }
using var context = new ConfectioneryDatabase(); using var context = new ConfectioneryDatabase();
return context.Pastries.FirstOrDefault return context.Pastries
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.FirstOrDefault
(x => (!string.IsNullOrEmpty(model.PastryName) && x.PastryName == model.PastryName) || (x => (!string.IsNullOrEmpty(model.PastryName) && x.PastryName == model.PastryName) ||
(model.Id.HasValue && x.Id == model.Id) (model.Id.HasValue && x.Id == model.Id)
)?.GetViewModel; )?.GetViewModel;