diff --git a/Workshop/Forms/FormCheque.cs b/Workshop/Forms/FormCheque.cs index 1d273f0..24b4db4 100644 --- a/Workshop/Forms/FormCheque.cs +++ b/Workshop/Forms/FormCheque.cs @@ -58,7 +58,7 @@ namespace Workshop.Forms return list.GroupBy( x => x.ProductId, x => x.Amount, - (id, counts) => ChequeProduct.CreateEntity(0, id, counts.Sum())).ToList(); + (id, counts) => ChequeProduct.CreateEntity(id, 0, counts.Sum())).ToList(); } } } diff --git a/Workshop/Reports/ChartReport.cs b/Workshop/Reports/ChartReport.cs index 8ecbacb..482f5f7 100644 --- a/Workshop/Reports/ChartReport.cs +++ b/Workshop/Reports/ChartReport.cs @@ -44,12 +44,12 @@ internal class ChartReport { return _creatingRepository .ReadProductCreates(dateFrom: dateTimeStart, dateTo: dateTimeEnd) - .GroupBy(x => x.ProductId, (key, group) => new + .GroupBy(x => x.ProductName, (key, group) => new { - Id = key, + ProductName = key, Count = group.Count() }) - .Select(x => (x.Id.ToString(), (double)x.Count)) + .Select(x => (x.ProductName.ToString(), (double)x.Count)) .ToList(); } } diff --git a/Workshop/Repositories/Implementations/ChequeRepository.cs b/Workshop/Repositories/Implementations/ChequeRepository.cs index c31e074..216e4ee 100644 --- a/Workshop/Repositories/Implementations/ChequeRepository.cs +++ b/Workshop/Repositories/Implementations/ChequeRepository.cs @@ -43,7 +43,7 @@ INSERT INTO CHEQUE_PRODUCT (ProductID, ChequeID, Amount) VALUES (@ProductId, @ChequeID, @Amount)"; foreach (var elem in cheque.ChequeProduct) { - connection.Execute(querySubInsert, new {chequeId, elem.ProductId, elem.Amount}); + connection.Execute(querySubInsert, new { elem.ProductId, chequeId, elem.Amount}); } transaction.Commit(); } @@ -61,9 +61,9 @@ VALUES (@ProductId, @ChequeID, @Amount)"; { var builder = new QueryBuilder(); if (dateFrom.HasValue) - builder.AddCondition("cp.CreatingDate >= @dateFrom"); + builder.AddCondition("c.Date >= @dateFrom"); if (dateTo.HasValue) - builder.AddCondition("cp.CreatingDate <= @dateTo"); + builder.AddCondition("c.Date <= @dateTo"); if (productId.HasValue) builder.AddCondition("cp.ProductId = @productId"); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);