diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs index 2d8ffa4..497dd80 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ReportClientLogic.cs @@ -39,6 +39,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic var paymeants = _paymeantstorage.GetFillteredList(new PaymeantSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo, + ClientID = model.ClientID, }); List? products = new(); @@ -91,17 +92,15 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic TotalCount = 0 }; - foreach (var payment in paymeants) { - var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID }) - ?? throw new Exception("Ошибка полуения данных"); + var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID }) + ?? throw new Exception("Ошибка полуения данных"); - foreach (var product in order.ProductList) { - record.Products.Add(new(product.Value.Item1.ProductName, product.Value.Item2)); - record.TotalCount += product.Value.Item2; - } - } - - list.Add(record); + foreach (var product in order.ProductList) { + record.Products.Add(new(product.Value.Item1.ProductName, product.Value.Item2)); + record.TotalCount += product.Value.Item2; + } + + list.Add(record); } return list; diff --git a/ElectronicsShop/ElectronicsShopContracts/BindingModels/ReportBindingModel.cs b/ElectronicsShop/ElectronicsShopContracts/BindingModels/ReportBindingModel.cs index e47daa5..fb0d9e7 100644 --- a/ElectronicsShop/ElectronicsShopContracts/BindingModels/ReportBindingModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/BindingModels/ReportBindingModel.cs @@ -13,5 +13,6 @@ namespace ElectronicsShopContracts.BindingModels public string ClientEmail { get; set; } = string.Empty; public DateTime DateFrom { get; set; } public DateTime DateTo { get; set; } + public int ClientID { get; set; } } } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs index 1aa237b..4ac0fa2 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/ClientController.cs @@ -113,6 +113,19 @@ namespace ElectronicsShopRestAPI.Controllers { } _payLogic.CreatePay(model); + var order = _orderLogic.ReadElement(new OrderSearchModel { ID = model.OrderID }); + + if (order == null) { + throw new Exception("Ошибка получения данных"); + } + + _orderLogic.Update(new OrderBindingModel { + ID = order.ID, + ClientID = order.ClientID, + DateCreate = order.DateCreate, + Sum = order.Sum - model.SumPayment, + ProductList = order.ProductList, + }); } if (model.PayOption == 0) { @@ -126,26 +139,11 @@ namespace ElectronicsShopRestAPI.Controllers { ID = model.OrderID, ClientID = order.ClientID, DateCreate = order.DateCreate, - Sum = order.Sum - model.SumPayment, + Sum = order.Sum, ProductList = order.ProductList, Status = OrderStatus.Оплачено }); } - else { - var order = _orderLogic.ReadElement(new OrderSearchModel { ID = model.OrderID }); - - if (order == null) { - throw new Exception("Ошибка получения данных"); - } - - _orderLogic.Update(new OrderBindingModel { - ID = order.ID, - ClientID = order.ClientID, - DateCreate = order.DateCreate, - Sum = order.Sum - model.SumPayment, - ProductList = order.ProductList, - }); - } } catch (Exception ex) { _logger.LogError(ex, "Ошибка создания оплаты"); diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Report b/ElectronicsShop/ElectronicsShopRestAPI/Report index e1f79e3..cca7381 100644 Binary files a/ElectronicsShop/ElectronicsShopRestAPI/Report and b/ElectronicsShop/ElectronicsShopRestAPI/Report differ diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs index b86ee6c..52fc3eb 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs @@ -274,6 +274,7 @@ namespace ElectronicsShopUserApp.Controllers { return PaymeantOption.; } } + [HttpPost] public double Calc(int count, int product) { var _product = APIClient.GetRequset($"api/main/getproduct?_productid={product}"); @@ -333,7 +334,8 @@ namespace ElectronicsShopUserApp.Controllers { APIClient.PostRequest("api/client/SendReportMail", new ReportBindingModel { ClientEmail = APIClient.Client?.Email ?? throw new Exception(" "), DateFrom = DateTime.Parse(DateFrom), - DateTo = DateTime.Parse(DateTo) + DateTo = DateTime.Parse(DateTo), + ClientID = APIClient.Client.ID }); return View("Report"); }