ОБНОВЛЕНИЕ РАБОТАЕТ

This commit is contained in:
dasha 2023-03-30 00:23:51 +04:00
parent 231063ed16
commit 1d8fc2ccac
4 changed files with 22 additions and 13 deletions

View File

@ -42,21 +42,25 @@ namespace BeautySaloonDatabaseImplement.Implements
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model) public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
{ {
using var context = new NewdbContext(); using var context = new NewdbContext();
if (string.IsNullOrEmpty(model.Surname) && !model.Id.HasValue)
{
return new();
}
if (model.Id.HasValue) if (model.Id.HasValue)
return context.Employees return context.Employees
.Include(x => x.Position) .Include(x => x.Position)
.Where(x => x.Id.Equals(model.Id)) .Where(x => x.Id.Equals(model.Id))
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
return context.Employees if (model.PositionId.HasValue)
.Include(x => x.Position) return context.Employees
.Where(x => x.Surname.Contains(model.Surname)) .Include(x => x.Position)
.Select(x => x.GetViewModel) .Where(x => x.PositionId.Equals(model.PositionId))
.ToList(); .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<EmployeeViewModel> GetFullList() public List<EmployeeViewModel> GetFullList()

View File

@ -14,6 +14,8 @@ namespace BeautySaloonDatabaseImplement.Implements
var element = context.Orders var element = context.Orders
.Include(x => x.Employee) .Include(x => x.Employee)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.ServiceOrders)
.ThenInclude(x => x.Service)
.FirstOrDefault(rec => rec.Id == model.Id); .FirstOrDefault(rec => rec.Id == model.Id);
if (element != null) if (element != null)
{ {
@ -29,8 +31,10 @@ namespace BeautySaloonDatabaseImplement.Implements
using var context = new NewdbContext(); using var context = new NewdbContext();
if (model.Id.HasValue) if (model.Id.HasValue)
return context.Orders return context.Orders
.Include(x => x.Employee)
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Employee)
.Include(x => x.ServiceOrders)
.ThenInclude(x => x.Service)
.FirstOrDefault(x => x.Id == model.Id)? .FirstOrDefault(x => x.Id == model.Id)?
.GetViewModel; .GetViewModel;
return null; return null;

View File

@ -97,7 +97,8 @@ public partial class Order : IOrderModel
ClientName = Client.Name + " " + Client.Surname + " " + Client.Patronymic, ClientName = Client.Name + " " + Client.Surname + " " + Client.Patronymic,
EmployeeName = Employee.Name + " " + Employee.Surname + " " + Employee.Patronymic, EmployeeName = Employee.Name + " " + Employee.Surname + " " + Employee.Patronymic,
ClientPhone = Client.Phone, ClientPhone = Client.Phone,
EmployeePhone = Employee.Phone EmployeePhone = Employee.Phone,
OrderServices = OrderServices
}; };
public void UpdateServices(NewdbContext context, OrderBindingModel model) public void UpdateServices(NewdbContext context, OrderBindingModel model)

View File

@ -28,7 +28,7 @@ namespace BeautySaloonView
// продавцы // продавцы
var list = _logicE.ReadList(new EmployeeSearchModel var list = _logicE.ReadList(new EmployeeSearchModel
{ {
Id = 1 PositionId = 1
}); });
if (list != null) if (list != null)
{ {
@ -42,7 +42,7 @@ namespace BeautySaloonView
{ {
var view = _logicO.ReadElement(new OrderSearchModel var view = _logicO.ReadElement(new OrderSearchModel
{ {
Id = _idClient.Value Id = _id
}); });
if (view != null) if (view != null)
{ {