Еще исправления

This commit is contained in:
Allllen4a 2024-04-30 14:48:26 +04:00
parent 8b40fd8b02
commit 7874978020
6 changed files with 30 additions and 63 deletions

View File

@ -6,6 +6,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="OfficePackage\**" />
<EmbeddedResource Remove="OfficePackage\**" />
<None Remove="OfficePackage\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
@ -17,9 +23,5 @@
<ItemGroup>
<ProjectReference Include="..\BeautySalonContracts\BeautySalonContracts.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="OfficePackage\" />
</ItemGroup>
</Project>

View File

@ -17,7 +17,6 @@ namespace BeautySalonContracts.StoragesContracts
EvaluationViewModel? Insert(EvaluationBindingModel model);
EvaluationViewModel? Update(EvaluationBindingModel model);
EvaluationViewModel? Delete(EvaluationBindingModel model);
int GetNumberOfPages(int userId, int pageSize);
}
}

View File

@ -18,14 +18,7 @@ namespace BeautySalonDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
public int GetNumberOfPages(int userId, int pageSize)
{
using var context = new BeautySalonDatabase();
int carsCount = context.LaborsCosts.Where(c => c.LaborCostsId == userId).Count();
int numberOfpages = (int)Math.Ceiling((double)carsCount / pageSize);
return numberOfpages != 0 ? numberOfpages : 1;
}
public List<CosmeticViewModel> GetFilteredList(CosmeticSearchModel model)
{
using var context = new BeautySalonDatabase();
@ -36,22 +29,14 @@ namespace BeautySalonDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
if (model.LaborCostsId.HasValue && model.PageNumber.HasValue && model.PageSize.HasValue)
if (model.LaborCostId.HasValue)
{
return context.Cosmetics
.Where(x => x.LaborCostsId == model.LaborCostsId)
.Skip(model.PageSize.Value * (model.PageNumber.Value - 1))
.Take(model.PageSize.Value)
.Where(x => x.LaborCostId == model.LaborCostId)
.Select(x => x.GetViewModel)
.ToList();
}
if (model.LaborCostsId.HasValue)
{
return context.Cosmetics
.Where(x => x.LaborCostsId == model.LaborCostsId)
.Select(x => x.GetViewModel)
.ToList();
}
return new();
}
@ -114,7 +99,7 @@ namespace BeautySalonDatabaseImplement.Implements
return new();
}
using var context = new BeautySalonDatabase();
var procedures = context.ProcedureCosmetics
var procedures = context.CosmeticProcedures
.Where(x => x.CosmeticId == model.Id)
.Select(x => x.Procedure.GetViewModel)
.ToList();

View File

@ -23,32 +23,23 @@ namespace BeautySalonDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
public int GetNumberOfPages(int userId, int pageSize)
{
using var context = new BeautySalonDatabase();
int carsCount = context.LaborsCosts.Where(c => c.StaffMemberId == userId).Count();
int numberOfpages = (int)Math.Ceiling((double)carsCount / pageSize);
return numberOfpages != 0 ? numberOfpages : 1;
}
public List<EvaluationViewModel> GetFilteredList(EvaluationSearchModel model)
{
using var context = new BeautySalonDatabase();
if (model.Id.HasValue)
{
return context.Ratings
return context.Evaluations
.Include(x => x.Procedure)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
if (model.ClientId.HasValue && model.PageNumber.HasValue && model.PageSize.HasValue)
if (model.ClientId.HasValue)
{
return context.Ratings
return context.Evaluations
.Include(x => x.Procedure)
.Where(x => x.ClientId == model.ClientId)
.Skip(model.PageSize.Value * (model.PageNumber.Value - 1))
.Take(model.PageSize.Value)
.Select(x => x.GetViewModel)
.ToList();
}
@ -62,7 +53,7 @@ namespace BeautySalonDatabaseImplement.Implements
return null;
}
using var context = new BeautySalonDatabase();
return context.Ratings
return context.Evaluations
.Include(x => x.Procedure)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
@ -76,9 +67,9 @@ namespace BeautySalonDatabaseImplement.Implements
return null;
}
using var context = new BeautySalonDatabase();
context.Ratings.Add(newRating);
context.Evaluations.Add(newRating);
context.SaveChanges();
return context.Ratings
return context.Evaluations
.Include(x => x.Procedure)
.FirstOrDefault(x => x.Id == newRating.Id)
?.GetViewModel;

View File

@ -17,10 +17,10 @@ namespace BeautySalonDatabaseImplement.Implements
public LaborCostsViewModel? Delete(LaborCostsBindingModel model)
{
using var context = new BeautySalonDatabase();
var element = context.LaborsCosts.FirstOrDefault(rec => rec.Id == model.Id);
var element = context.LaborCosts.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.LaborsCosts.Remove(element);
context.LaborCosts.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
@ -34,35 +34,25 @@ namespace BeautySalonDatabaseImplement.Implements
return null;
}
using var context = new BeautySalonDatabase();
return context.LaborsCosts
return context.LaborCosts
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public int GetNumberOfPages(int userId, int pageSize)
{
using var context = new BeautySalonDatabase();
int carsCount = context.LaborsCosts.Where(c => c.LaborCostsId == userId).Count();
int numberOfpages = (int)Math.Ceiling((double)carsCount / pageSize);
return numberOfpages != 0 ? numberOfpages : 1;
}
public List<LaborCostsViewModel> GetFilteredList(LaborCostsSearchModel model)
{
using var context = new BeautySalonDatabase();
if (model.Id.HasValue)
{
return context.LaborsCosts
return context.LaborCosts
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
if (model.LaborCostsId.HasValue && model.PageNumber.HasValue && model.PageSize.HasValue)
if (model.Id.HasValue)
{
return context.LaborsCosts
.Where(x => x.LaborCostsId == model.LaborCostsId)
.Skip(model.PageSize.Value * (model.PageNumber.Value - 1))
.Take(model.PageSize.Value)
return context.LaborCosts
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
@ -72,7 +62,7 @@ namespace BeautySalonDatabaseImplement.Implements
public List<LaborCostsViewModel> GetFullList()
{
using var context = new BeautySalonDatabase();
return context.LaborsCosts
return context.LaborCosts
.Select(x => x.GetViewModel)
.ToList();
}
@ -85,7 +75,7 @@ namespace BeautySalonDatabaseImplement.Implements
return null;
}
using var context = new BeautySalonDatabase();
context.LaborsCosts.Add(newLaborCosts);
context.LaborCosts.Add(newLaborCosts);
context.SaveChanges();
return newLaborCosts.GetViewModel;
}
@ -93,7 +83,7 @@ namespace BeautySalonDatabaseImplement.Implements
public LaborCostsViewModel? Update(LaborCostsBindingModel model)
{
using var context = new BeautySalonDatabase();
var laborCosts = context.LaborsCosts.FirstOrDefault(x => x.Id == model.Id);
var laborCosts = context.LaborCosts.FirstOrDefault(x => x.Id == model.Id);
if (laborCosts == null)
{
return null;

View File

@ -66,7 +66,7 @@ namespace BeautySalonDatabaseImplement.Implements
.ThenInclude(x => x.Service)
.Include(x => x.Procedures)
.ThenInclude(x => x.Procedure)
.ThenInclude(x => x.Ratings)
.ThenInclude(x => x.Evaluations)
.Where(x => x.ClientId == model.ClientId &&
x.OrderDate >= model.DateFrom && x.OrderDate <= model.DateTo).ToList()
.Select(x => x.GetViewModel)