вроде всё

This commit is contained in:
Николай 2023-04-02 17:15:03 +04:00
parent 2debfe4ba8
commit 3dd37697c8
6 changed files with 0 additions and 63 deletions

View File

@ -118,25 +118,5 @@ namespace HardwareShopContracts.BusinessLogicsContracts
throw new InvalidOperationException("Продукт с таким названием уже есть");
}
}
//нужно переделать
public double Price(ComponentSearchModel model)
{
_logger.LogInformation("ReadList. Id:{Id}", model?.Id);
var list = _componentStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return 0;
}
double sum = 0;
foreach (var component in list)
{
sum += component.Cost;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return sum;
}
}
}

View File

@ -123,23 +123,5 @@ namespace HardwareShopContracts.BusinessLogicsContracts
}
_logger.LogInformation("Purchase. UserId:{UserId}. PurchaseID:{Id}. Sum:{ Sum}", model.UserId, model.Id, model.Sum);
}
public double Price(PurchaseSearchModel model)
{
_logger.LogInformation("ReadList. Id:{Id}", model?.Id);
var list = _purchaseStorage.GetFilteredListBuild(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return 0;
}
double sum = 0;
foreach (var build in list)
{
sum += build.Value.Item1* build.Value.Item2.Price;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return sum;
}
}
}

View File

@ -8,7 +8,6 @@ namespace HardwareShopContracts.BusinessLogicsContracts
{
List<BuildViewModel>? ReadList(BuildSearchModel? model);
BuildViewModel? ReadElement(BuildSearchModel model);
double Price(ComponentSearchModel model);
bool Create(BuildBindingModel model);
bool Update(BuildBindingModel model);
bool Delete(BuildBindingModel model);

View File

@ -8,7 +8,6 @@ namespace HardwareShopContracts.BusinessLogicsContracts
{
List<PurchaseViewModel>? ReadList(PurchaseSearchModel? model);
CommentViewModel? ReadElement(CommentSearchModel model);
double Price(PurchaseSearchModel model);
bool Create(PurchaseBindingModel model);
bool Update(PurchaseBindingModel model);
bool Delete(PurchaseBindingModel model);

View File

@ -9,7 +9,6 @@ namespace HardwareShopContracts.StoragesContracts
{
List<PurchaseViewModel> GetFullList();
List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model);
Dictionary<int, (int, IBuildModel)> GetFilteredListBuild(PurchaseSearchModel model);
PurchaseViewModel? GetElement(PurchaseSearchModel model);
PurchaseViewModel? Insert(PurchaseBindingModel model);
PurchaseViewModel? Update(PurchaseBindingModel model);

View File

@ -15,7 +15,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
{
using var context = new HardwareShopDatabase();
return context.Purchases
.Include(x => x.Builds)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.Include(x => x.User)
@ -31,7 +30,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
return new();
}
return context.Purchases
.Include(x => x.Builds)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.Include(x => x.User)
@ -40,22 +38,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
.ToList();
}
public Dictionary<int, (int, IBuildModel)> GetFilteredListBuild(PurchaseSearchModel model)
{
using var context = new HardwareShopDatabase();
var listBuilds = context.PurchasesBuilds
.Include(x => x.Build)
.Where(x => x.PurchaseId == model.Id)
.ToList();
Dictionary<int,(int, IBuildModel)>? _purchaseBuilds = null;
foreach(var build in listBuilds)
{
_purchaseBuilds.Add(build.BuildId, (build.Count, build.Build));
}
return _purchaseBuilds;
}
public PurchaseViewModel? GetElement(PurchaseSearchModel model)
{
if (!model.Id.HasValue)
@ -64,7 +46,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
}
using var context = new HardwareShopDatabase();
return context.Purchases
.Include(x => x.Builds)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.Include(x => x.User)
@ -83,7 +64,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
context.Purchases.Add(newPurchase);
context.SaveChanges();
return context.Purchases
.Include(x => x.Builds)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.Include(x => x.User)
@ -98,7 +78,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
try
{
var purchase = context.Purchases
.Include(x => x.Builds)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.Include(x => x.User)
@ -124,7 +103,6 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
{
using var context = new HardwareShopDatabase();
var element = context.Purchases
.Include(x => x.Builds)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.Include(x => x.User)