Agliullov D. A. Lab Work 3 Hard #7

Closed
d.agliullov wants to merge 15 commits from Lab3_Hard into Lab2_Hard
Showing only changes of commit f2ca847c6b - Show all commits

View File

@ -4,6 +4,7 @@ using ConfectioneryContracts.StoragesContract;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDatabaseImplement;
using ConfectioneryDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace ConfectioneryDatabaseImplement.Implements
{
@ -29,7 +30,10 @@ namespace ConfectioneryDatabaseImplement.Implements
return null;
}
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) ||
(model.Id.HasValue && x.Id == model.Id)
)?.GetViewModel;