спасибо за отчет миру

This commit is contained in:
dasha 2023-04-05 00:21:12 +04:00
parent eb08556e88
commit b1f517a3e2
4 changed files with 34 additions and 34 deletions

View File

@ -25,13 +25,17 @@ namespace HardwareShopBusinessLogic.BusinessLogics.Storekeeper
} }
public List<ReportBuildGoodViewModel> GetBuildGood(List<GoodViewModel> goods) public List<ReportBuildGoodViewModel> GetBuildGood(List<GoodViewModel> goods)
{ {
/*var result = new List<ReportBuildGoodViewModel>(); var result = new List<ReportBuildGoodViewModel>();
foreach (var good in goods) foreach (var good in goods)
{ {
var builds = good.GoodComponents? var builds = good.GoodComponents
.SelectMany(x => x.Value.Item1.ComponentBuilds //получили сборки и количество компонентов
.Select(y => y.Value.Item1.BuildName)) .Select(x => _componentStorage.GetComponentBuilds(new() { Id = x.Key })
//если кол-во компонентов в товаре == кол-ву в сборке
.Where(y => x.Value.Item2 == y.Item2))
.SelectMany(x => x.Select(x => x.Item1))
.Distinct()
.ToList(); .ToList();
ReportBuildGoodViewModel record = new() ReportBuildGoodViewModel record = new()
{ {
@ -40,30 +44,7 @@ namespace HardwareShopBusinessLogic.BusinessLogics.Storekeeper
}; };
result.Add(record); result.Add(record);
} }
return result;*/ return result;
var list = new List<ReportBuildGoodViewModel>();
var builds = _buildStorage.GetFullList();
foreach (var good in goods)
{
var record = new ReportBuildGoodViewModel
{
GoodName = good.GoodName,
Builds = new()
};
var components = good.GoodComponents;
foreach (var build in builds)
{
// сработает ли такая проверка?
if (build.BuildComponents == good.GoodComponents)
{
builds.Add(build);
}
}
}
return list;
} }
public List<ReportComponentsViewModel> GetComponents(ReportBindingModel model) public List<ReportComponentsViewModel> GetComponents(ReportBindingModel model)

View File

@ -1,4 +1,9 @@
/*using HardwareShopClientApp; using HardwareShopClientApp;
using HardwareShopBusinessLogic.BusinessLogics.Storekeeper;
using HardwareShopDatabaseImplement.Implements.Storekeeper;
using HardwareShopDatabaseImplement.Implements.Worker;
/*
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -26,12 +31,10 @@ app.MapControllerRoute(
name: "default", name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"); pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run(); //app.Run();
*/ */
using HardwareShopBusinessLogic.BusinessLogics.Storekeeper;
using HardwareShopDatabaseImplement.Implements.Storekeeper;
using HardwareShopDatabaseImplement.Implements.Worker;
ComponentStorage _componentStorage = new(); ComponentStorage _componentStorage = new();
GoodStorage _goodStorage = new(); GoodStorage _goodStorage = new();
@ -54,3 +57,4 @@ foreach (var reportRecord in reportRecords)
} }
Console.WriteLine(); Console.WriteLine();
} }

View File

@ -12,5 +12,6 @@ namespace HardwareShopContracts.StoragesContracts
ComponentViewModel? Insert(ComponentBindingModel model); ComponentViewModel? Insert(ComponentBindingModel model);
ComponentViewModel? Update(ComponentBindingModel model); ComponentViewModel? Update(ComponentBindingModel model);
ComponentViewModel? Delete(ComponentBindingModel model); ComponentViewModel? Delete(ComponentBindingModel model);
List<Tuple<string, int>> GetComponentBuilds(ComponentSearchModel model);
} }
} }

View File

@ -118,5 +118,19 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
throw; throw;
} }
} }
public List<Tuple<string, int>> GetComponentBuilds(ComponentSearchModel model)
{
if (model == null)
{
return new();
}
using var context = new HardwareShopDatabase();
var builds = context.ComponentsBuilds
.Where(x => x.ComponentId == model.Id)
.Select(x => new Tuple<string, int>(x.Build.BuildName, x.Count))
.ToList();
return builds;
}
} }
} }