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) {