еще правки
This commit is contained in:
parent
34e2825c61
commit
586ad5562a
@ -12,6 +12,6 @@ namespace BeautySalonContracts.BusinessLogicContracts
|
||||
bool Create(OrderBindingModel model);
|
||||
bool Delete(OrderBindingModel model);
|
||||
bool Update(OrderBindingModel model);
|
||||
int GetNumberOfPages(int userId, int pageSize = 10);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ namespace BeautySalonContracts.StoragesContracts
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
int GetNumberOfPages(int userId, int pageSize);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,5 +19,6 @@ namespace BeautySalonContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
public List<OrderServiceViewModel> OrderServices { get; set; } = new();
|
||||
public List<OrderProcedureViewModel> OrderProcedures { get; set; } = new();
|
||||
public List<OrderCosmeticViewModel> OrderCosmetics { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
|
||||
namespace BeautySalonDatabaseImplement
|
||||
{
|
||||
@ -21,6 +22,8 @@ namespace BeautySalonDatabaseImplement
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
|
||||
public virtual DbSet<Order_> Orders { set; get; }
|
||||
public virtual DbSet<LaborCosts> LaborCosts { set; get; }
|
||||
public virtual DbSet<Cosmetic> Cosmetics { set; get; }
|
||||
|
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -20,6 +21,7 @@ namespace BeautySalonDatabaseImplement.Implements
|
||||
var element = context.Orders
|
||||
.Include(x => x.Services)
|
||||
.Include(x => x.Procedures)
|
||||
.Include(x => x.Cosmetics)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
@ -42,16 +44,12 @@ namespace BeautySalonDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Service)
|
||||
.Include(x => x.Procedures)
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.Include(x => x.Cosmetics)
|
||||
.ThenInclude(x => x.Cosmetic)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public int GetNumberOfPages(int userId, int pageSize)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
int carsCount = context.Orders.Where(c => c.ClientId == userId).Count();
|
||||
int numberOfpages = (int)Math.Ceiling((double)carsCount / pageSize);
|
||||
return numberOfpages != 0 ? numberOfpages : 1;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -66,7 +64,8 @@ namespace BeautySalonDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Service)
|
||||
.Include(x => x.Procedures)
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.ThenInclude(x => x.Evaluations)
|
||||
.Include(x => x.Cosmetics)
|
||||
.ThenInclude(x => x.Cosmetic)
|
||||
.Where(x => x.ClientId == model.ClientId &&
|
||||
x.OrderDate == model.OrderDate).ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -92,6 +91,8 @@ namespace BeautySalonDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Service)
|
||||
.Include(x => x.Procedures)
|
||||
.ThenInclude(x => x.Procedure)
|
||||
.Include(x => x.Cosmetics)
|
||||
.ThenInclude(x => x.Cosmetic)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
Loading…
Reference in New Issue
Block a user