Исправление отчета + бага бд

This commit is contained in:
dasha 2023-04-06 21:51:10 +04:00
parent 3244f9d2ea
commit 07ebb8d635
4 changed files with 29 additions and 5 deletions

View File

@ -54,9 +54,8 @@ namespace HardwareShopBusinessLogic.BusinessLogics.Storekeeper
.Select(x => Tuple.Create(x.Value.Item1.BuildName, x.Value.Item2)) .Select(x => Tuple.Create(x.Value.Item1.BuildName, x.Value.Item2))
.ToList(); .ToList();
var goods = component.ComponentBuilds var goods = _componentStorage
.SelectMany(x => .GetComponentGoods(new() { Id = component.Id })
_componentStorage.GetComponentGoods(new() { Id = x.Key }))
.ToList(); .ToList();
ReportComponentsViewModel record = new() ReportComponentsViewModel record = new()

View File

@ -1,4 +1,4 @@
using HardwareShopClientApp; /*using HardwareShopClientApp;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -27,3 +27,27 @@ app.MapControllerRoute(
pattern: "{controller=Home}/{action=Index}/{id?}"); pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run(); app.Run();
*/
using HardwareShopBusinessLogic.BusinessLogics.Storekeeper;
using HardwareShopDatabaseImplement.Implements.Storekeeper;
ComponentStorage _componentStorage = new();
ReportStorekeeperLogic reportLogic = new(_componentStorage);
var reportRecords = reportLogic.GetComponents(new() { Id = 1 },
new() { DateFrom = DateTime.MinValue, DateTo = DateTime.Now });
Console.WriteLine("start");
Console.WriteLine(reportRecords.Count);
foreach (var reportRecord in reportRecords)
{
Console.WriteLine("components: " + reportRecord.ComponentName);
Console.WriteLine("> good/build: ");
for (int i = 0; i < reportRecord.GoodOrBuilds.Count; i++)
{
Console.WriteLine(i + 1 + ". " + reportRecord.GoodOrBuilds[i].Item1
+ ". Count - " + reportRecord.GoodOrBuilds[i].Item2);
}
Console.WriteLine("Èòîãî - " + reportRecord.TotalCount);
}

View File

@ -11,6 +11,7 @@ namespace HardwareShopDatabaseImplement
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
optionsBuilder.UseNpgsql("Host=localhost;Port=5433;Database=Computer_Hardware_Store;Username=user;Password=12345"); optionsBuilder.UseNpgsql("Host=localhost;Port=5433;Database=Computer_Hardware_Store;Username=user;Password=12345");
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
} }
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)

View File

@ -138,7 +138,7 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper
using var context = new HardwareShopDatabase(); using var context = new HardwareShopDatabase();
var builds = context.ComponentsBuilds var builds = context.ComponentsBuilds
.Where(x => x.ComponentId == model.Id) .Where(x => x.ComponentId == model.Id)
.Select(x => new Tuple<string, int>(x.Build.BuildName, x.Count)) .Select(x => Tuple.Create(x.Build.BuildName, x.Count))
.ToList(); .ToList();
return builds; return builds;
} }