diff --git a/HardwareShop/HardwareShopBusinessLogic/BusinessLogics/Storekeeper/ReportStorekeeperLogic.cs b/HardwareShop/HardwareShopBusinessLogic/BusinessLogics/Storekeeper/ReportStorekeeperLogic.cs index 6e26152..e10369e 100644 --- a/HardwareShop/HardwareShopBusinessLogic/BusinessLogics/Storekeeper/ReportStorekeeperLogic.cs +++ b/HardwareShop/HardwareShopBusinessLogic/BusinessLogics/Storekeeper/ReportStorekeeperLogic.cs @@ -54,9 +54,8 @@ namespace HardwareShopBusinessLogic.BusinessLogics.Storekeeper .Select(x => Tuple.Create(x.Value.Item1.BuildName, x.Value.Item2)) .ToList(); - var goods = component.ComponentBuilds - .SelectMany(x => - _componentStorage.GetComponentGoods(new() { Id = x.Key })) + var goods = _componentStorage + .GetComponentGoods(new() { Id = component.Id }) .ToList(); ReportComponentsViewModel record = new() diff --git a/HardwareShop/HardwareShopClientApp/Program.cs b/HardwareShop/HardwareShopClientApp/Program.cs index 9ff3bc8..e3ee9ec 100644 --- a/HardwareShop/HardwareShopClientApp/Program.cs +++ b/HardwareShop/HardwareShopClientApp/Program.cs @@ -1,4 +1,4 @@ -using HardwareShopClientApp; +/*using HardwareShopClientApp; var builder = WebApplication.CreateBuilder(args); @@ -27,3 +27,27 @@ app.MapControllerRoute( pattern: "{controller=Home}/{action=Index}/{id?}"); 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); +} \ No newline at end of file diff --git a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs index 90abdf7..86c4efc 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs @@ -11,6 +11,7 @@ namespace HardwareShopDatabaseImplement protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { 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) diff --git a/HardwareShop/HardwareShopDatabaseImplement/Implements/Storekeeper/ComponentStorage.cs b/HardwareShop/HardwareShopDatabaseImplement/Implements/Storekeeper/ComponentStorage.cs index add17ef..9bcb78e 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/Implements/Storekeeper/ComponentStorage.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/Implements/Storekeeper/ComponentStorage.cs @@ -138,7 +138,7 @@ namespace HardwareShopDatabaseImplement.Implements.Storekeeper using var context = new HardwareShopDatabase(); var builds = context.ComponentsBuilds .Where(x => x.ComponentId == model.Id) - .Select(x => new Tuple(x.Build.BuildName, x.Count)) + .Select(x => Tuple.Create(x.Build.BuildName, x.Count)) .ToList(); return builds; }