From 1d8fc2ccac00ee0243f25c5e631d8014d8564f74 Mon Sep 17 00:00:00 2001 From: dasha Date: Thu, 30 Mar 2023 00:23:51 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=91=D0=9D=D0=9E=D0=92=D0=9B=D0=95?= =?UTF-8?q?=D0=9D=D0=98=D0=95=20=D0=A0=D0=90=D0=91=D0=9E=D0=A2=D0=90=D0=95?= =?UTF-8?q?=D0=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/EmployeeStorage.cs | 22 +++++++++++-------- .../Implements/OrderStorage.cs | 6 ++++- .../BeautySaloonDatabaseImplement/Order.cs | 3 ++- .../BeautySaloonView/FormCreateOrder.cs | 4 ++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/BeautySaloon/BeautySaloonDatabaseImplement/Implements/EmployeeStorage.cs b/BeautySaloon/BeautySaloonDatabaseImplement/Implements/EmployeeStorage.cs index 0442396..7accae9 100644 --- a/BeautySaloon/BeautySaloonDatabaseImplement/Implements/EmployeeStorage.cs +++ b/BeautySaloon/BeautySaloonDatabaseImplement/Implements/EmployeeStorage.cs @@ -42,21 +42,25 @@ namespace BeautySaloonDatabaseImplement.Implements public List GetFilteredList(EmployeeSearchModel model) { using var context = new NewdbContext(); - if (string.IsNullOrEmpty(model.Surname) && !model.Id.HasValue) - { - return new(); - } if (model.Id.HasValue) return context.Employees .Include(x => x.Position) .Where(x => x.Id.Equals(model.Id)) .Select(x => x.GetViewModel) .ToList(); - return context.Employees - .Include(x => x.Position) - .Where(x => x.Surname.Contains(model.Surname)) - .Select(x => x.GetViewModel) - .ToList(); + if (model.PositionId.HasValue) + return context.Employees + .Include(x => x.Position) + .Where(x => x.PositionId.Equals(model.PositionId)) + .Select(x => x.GetViewModel) + .ToList(); + if (!string.IsNullOrEmpty(model.Surname)) + return context.Employees + .Include(x => x.Position) + .Where(x => x.Surname.Contains(model.Surname)) + .Select(x => x.GetViewModel) + .ToList(); + return new(); } public List GetFullList() diff --git a/BeautySaloon/BeautySaloonDatabaseImplement/Implements/OrderStorage.cs b/BeautySaloon/BeautySaloonDatabaseImplement/Implements/OrderStorage.cs index 1b61d07..896adb3 100644 --- a/BeautySaloon/BeautySaloonDatabaseImplement/Implements/OrderStorage.cs +++ b/BeautySaloon/BeautySaloonDatabaseImplement/Implements/OrderStorage.cs @@ -14,6 +14,8 @@ namespace BeautySaloonDatabaseImplement.Implements var element = context.Orders .Include(x => x.Employee) .Include(x => x.Client) + .Include(x => x.ServiceOrders) + .ThenInclude(x => x.Service) .FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { @@ -29,8 +31,10 @@ namespace BeautySaloonDatabaseImplement.Implements using var context = new NewdbContext(); if (model.Id.HasValue) return context.Orders - .Include(x => x.Employee) .Include(x => x.Client) + .Include(x => x.Employee) + .Include(x => x.ServiceOrders) + .ThenInclude(x => x.Service) .FirstOrDefault(x => x.Id == model.Id)? .GetViewModel; return null; diff --git a/BeautySaloon/BeautySaloonDatabaseImplement/Order.cs b/BeautySaloon/BeautySaloonDatabaseImplement/Order.cs index 579b882..5a93c89 100644 --- a/BeautySaloon/BeautySaloonDatabaseImplement/Order.cs +++ b/BeautySaloon/BeautySaloonDatabaseImplement/Order.cs @@ -97,7 +97,8 @@ public partial class Order : IOrderModel ClientName = Client.Name + " " + Client.Surname + " " + Client.Patronymic, EmployeeName = Employee.Name + " " + Employee.Surname + " " + Employee.Patronymic, ClientPhone = Client.Phone, - EmployeePhone = Employee.Phone + EmployeePhone = Employee.Phone, + OrderServices = OrderServices }; public void UpdateServices(NewdbContext context, OrderBindingModel model) diff --git a/BeautySaloon/BeautySaloonView/FormCreateOrder.cs b/BeautySaloon/BeautySaloonView/FormCreateOrder.cs index e38b30a..1851261 100644 --- a/BeautySaloon/BeautySaloonView/FormCreateOrder.cs +++ b/BeautySaloon/BeautySaloonView/FormCreateOrder.cs @@ -28,7 +28,7 @@ namespace BeautySaloonView // продавцы var list = _logicE.ReadList(new EmployeeSearchModel { - Id = 1 + PositionId = 1 }); if (list != null) { @@ -42,7 +42,7 @@ namespace BeautySaloonView { var view = _logicO.ReadElement(new OrderSearchModel { - Id = _idClient.Value + Id = _id }); if (view != null) {