починил услугу и чет еще

This commit is contained in:
Milana Ievlewa 2024-04-30 15:20:40 +03:00
parent 4af879f620
commit b340839595
2 changed files with 5 additions and 26 deletions

View File

@ -59,7 +59,7 @@ namespace BeautySalonDatabaseImplement.Implements
return new();
}
using var context = new BeautySalonDatabase();
if (model.ClientId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
if (model.ClientId.HasValue && model.OrderDate.HasValue)
{
return context.Orders
.Include(x => x.Services)
@ -68,18 +68,7 @@ namespace BeautySalonDatabaseImplement.Implements
.ThenInclude(x => x.Procedure)
.ThenInclude(x => x.Evaluations)
.Where(x => x.ClientId == model.ClientId &&
x.OrderDate >= model.DateFrom && x.OrderDate <= model.DateTo).ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.ClientId.HasValue && model.PageNumber.HasValue && model.PageSize.HasValue)
{
return context.Orders
.Include(x => x.Services)
.ThenInclude(x => x.Service)
.Where(x => x.ClientId == model.ClientId)
.Skip(model.PageSize.Value * (model.PageNumber.Value - 1))
.Take(model.PageSize.Value)
x.OrderDate == model.OrderDate).ToList()
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -48,7 +48,7 @@ namespace BeautySalonDatabaseImplement.Implements
public int GetNumberOfPages(int userId, int pageSize)
{
using var context = new BeautySalonDatabase();
int carsCount = context.Services.Where(c => c.LaborCostsId == userId).Count();
int carsCount = context.Services.Where(c => c.Id == userId).Count();
int numberOfpages = (int)Math.Ceiling((double)carsCount / pageSize);
return numberOfpages != 0 ? numberOfpages : 1;
}
@ -60,25 +60,15 @@ namespace BeautySalonDatabaseImplement.Implements
return new();
}
using var context = new BeautySalonDatabase();
if (model.LaborCostsId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
if (model.Id.HasValue)
{
return context.Services
.Include(x => x.Cosmetics)
.ThenInclude(x => x.Cosmetic)
.Where(x => x.LaborCostsId == model.LaborCostsId &&
x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Where(x => x.Id == model.Id)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.LaborCostsId.HasValue && model.PageNumber.HasValue && model.PageSize.HasValue)
{
return context.Services
.Where(x => x.LaborCostsId == model.LaborCostsId)
.Skip(model.PageSize.Value * (model.PageNumber.Value - 1))
.Take(model.PageSize.Value)
.Select(x => x.GetViewModel)
.ToList();
}
return new();
}