From a46290e4d474c870ca8a3d78cc6f95a01685d759 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Fri, 19 May 2023 01:53:16 +0400 Subject: [PATCH] Save of diagrams. --- .../BusinessLogics/AccountLogic.cs | 19 ++++++++++++------- .../Controllers/HomeController.cs | 7 +++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs index c6eb154..bb31910 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/AccountLogic.cs @@ -151,23 +151,28 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics AccountId = AccountId, }).GroupBy(x => new { x.DateOperation.Month, x.DateOperation.Year }) .Select(x => new { x.Key.Month, x.Key.Year, Sum = x.Select(y => y.Sum).Sum() }).ToDictionary(x => (x.Month, x.Year), x => (x.Sum)); - Dictionary<(int, int), int> moneyTransfersDebiting = _moneyTransferLogic.ReadList(new MoneyTransferSearchModel() + + Dictionary<(int, int), int> moneyTransfers = _moneyTransferLogic.ReadList(new MoneyTransferSearchModel() { AccountPayeeId = AccountId, }).GroupBy(x => new { x.DateOperation.Month, x.DateOperation.Year }) .Select(x => new { x.Key.Month, x.Key.Year, Sum = x.Select(y => y.Sum).Sum() }).ToDictionary(x => (x.Month, x.Year), x => (x.Sum)); - Dictionary<(int, int), int> moneyTransfers = _moneyTransferLogic.ReadList(new MoneyTransferSearchModel() + + Dictionary<(int, int), int> moneyTransfersDebiting = _moneyTransferLogic.ReadList(new MoneyTransferSearchModel() { AccountSenderId = AccountId, }).GroupBy(x => new { x.DateOperation.Month, x.DateOperation.Year }) .Select(x => new { x.Key.Month, x.Key.Year, Sum = x.Select(y => y.Sum).Sum() }).ToDictionary(x => (x.Month, x.Year), x => (x.Sum)); + List result = new(); - foreach (var key in cashWithdrawals.Keys.Union(moneyTransfersDebiting.Keys).Union(moneyTransfers.Keys)) + + int sum = 0; + + foreach (var key in cashWithdrawals.Keys.Union(moneyTransfers.Keys).Union(moneyTransfers.Keys)) { - int sum = 0; - if (cashWithdrawals.ContainsKey(key)) sum -= cashWithdrawals.GetValueOrDefault(key); - if (moneyTransfersDebiting.ContainsKey(key)) sum += moneyTransfersDebiting.GetValueOrDefault(key); - if (moneyTransfersDebiting.ContainsKey(key)) sum -= moneyTransfersDebiting.GetValueOrDefault(key); + if (cashWithdrawals.ContainsKey(key)) sum += cashWithdrawals.GetValueOrDefault(key); + if (moneyTransfers.ContainsKey(key)) sum += moneyTransfers.GetValueOrDefault(key); + if (moneyTransfers.ContainsKey(key)) sum -= moneyTransfersDebiting.GetValueOrDefault(key); result.Add(new CashierDiagramElementsViewModel() { Name = Enum.GetName(typeof(Months), key.Item1) + " " + key.Item2.ToString(), Value = sum }); } return result; diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index ec4a8b3..8a6aef4 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -217,10 +217,9 @@ namespace BankYouBankruptClientApp.Controllers { return Redirect("~/Home/Enter"); } - - ViewBag.Cards = View(APIClient.GetRequest>($"api/Client/getUsersCreditings?userId={APIClient.Client.Id}")); - - return View(); + + ViewBag.Cards = APIClient.GetRequest>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}"); + return View(); } [HttpPost]