Save of diagrams.

This commit is contained in:
Programmist73 2023-05-19 01:53:16 +04:00
parent 5f765a77cf
commit a46290e4d4
2 changed files with 15 additions and 11 deletions

View File

@ -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<CashierDiagramElementsViewModel> 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;

View File

@ -217,10 +217,9 @@ namespace BankYouBankruptClientApp.Controllers
{
return Redirect("~/Home/Enter");
}
ViewBag.Cards = View(APIClient.GetRequest<List<CreditingViewModel>>($"api/Client/getUsersCreditings?userId={APIClient.Client.Id}"));
return View();
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}");
return View();
}
[HttpPost]