From f2ca847c6b93bf145ea4b03acacc52803e08b455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Tue, 28 Feb 2023 22:19:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=20=D0=B8=D0=B7?= =?UTF-8?q?=20=D0=B1=D0=B4=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=B5=20=D1=81?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=B4=D0=B5=D0=BB=D0=B8=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConfectioneryDatabaseImplement/PastryStorage.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ConfectioneryDatabaseImplement/PastryStorage.cs b/ConfectioneryDatabaseImplement/PastryStorage.cs index 84af032..aed74f0 100644 --- a/ConfectioneryDatabaseImplement/PastryStorage.cs +++ b/ConfectioneryDatabaseImplement/PastryStorage.cs @@ -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;