diff --git a/Bank/BankManagersClientApp/Controllers/HomeController.cs b/Bank/BankManagersClientApp/Controllers/HomeController.cs index a22d14e..812afc2 100644 --- a/Bank/BankManagersClientApp/Controllers/HomeController.cs +++ b/Bank/BankManagersClientApp/Controllers/HomeController.cs @@ -6,6 +6,7 @@ using BankDataModels.Models; using BankManagersClientApp.Models; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; +using System.Globalization; namespace BankManagersClientApp.Controllers { @@ -528,11 +529,152 @@ namespace BankManagersClientApp.Controllers Email = APIClient.Client.Email, }); Response.Redirect("Index"); - } - #endregion + } - #region//Error - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [HttpGet] + public string GetTransfersWithdrawals(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + List result; + try + { + string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture); + string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture); + result = APIClient.GetRequest> + ($"api/report/gettransferswithdrawals?datefrom={dateFromS}&dateto={dateToS}")!; + } + catch + { + _logger.LogError("Ошибка создания отчета"); + throw; + } + //sender transfers + string senderTransfersTable = ""; + senderTransfersTable += "

Переводы на другие счета

"; + senderTransfersTable += "
"; + senderTransfersTable += ""; + senderTransfersTable += ""; + senderTransfersTable += ""; + senderTransfersTable += ""; + senderTransfersTable += ""; + senderTransfersTable += ""; + senderTransfersTable += ""; + senderTransfersTable += ""; + senderTransfersTable += ""; + senderTransfersTable += ""; + senderTransfersTable += ""; + foreach (var report in result) + { + senderTransfersTable += ""; + senderTransfersTable += $""; + senderTransfersTable += $""; + senderTransfersTable += $""; + senderTransfersTable += $""; + senderTransfersTable += $""; + senderTransfersTable += ""; + foreach (var senderTransfer in report.SenderTransfers) + { + senderTransfersTable += ""; + senderTransfersTable += $""; + senderTransfersTable += $""; + senderTransfersTable += $""; + senderTransfersTable += $""; + senderTransfersTable += $""; + senderTransfersTable += ""; + } + } + senderTransfersTable += ""; + senderTransfersTable += "
Номер счётаНомер переводаВремя переводаСуммаНомер счёта получателя
{report.AccountNumber}
{senderTransfer.Id}{senderTransfer.TransferTime}{senderTransfer.Sum}{senderTransfer.RecipientAccountNumber}
"; + senderTransfersTable += "
"; + //recipient transfers + string recipientTransfersTable = ""; + recipientTransfersTable += "

Переводы с других счетов

"; + recipientTransfersTable += "
"; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + recipientTransfersTable += ""; + foreach (var report in result) + { + recipientTransfersTable += ""; + recipientTransfersTable += $""; + recipientTransfersTable += $""; + recipientTransfersTable += $""; + recipientTransfersTable += $""; + recipientTransfersTable += $""; + recipientTransfersTable += ""; + foreach (var recipientTransfer in report.RecipientTransfers) + { + recipientTransfersTable += ""; + recipientTransfersTable += $""; + recipientTransfersTable += $""; + recipientTransfersTable += $""; + recipientTransfersTable += $""; + recipientTransfersTable += $""; + recipientTransfersTable += ""; + } + } + recipientTransfersTable += ""; + recipientTransfersTable += "
Номер счётаНомер переводаВремя переводаСуммаНомер счёта отправителя
{report.AccountNumber}
{recipientTransfer.Id}{recipientTransfer.TransferTime}{recipientTransfer.Sum}{recipientTransfer.SenderAccountNumber}
"; + recipientTransfersTable += "
"; + //withdrawals + string withdrawalsTable = ""; + withdrawalsTable += "

Выдачи наличных

"; + withdrawalsTable += "
"; + withdrawalsTable += ""; + withdrawalsTable += ""; + withdrawalsTable += ""; + withdrawalsTable += ""; + withdrawalsTable += ""; + withdrawalsTable += ""; + withdrawalsTable += ""; + withdrawalsTable += ""; + withdrawalsTable += ""; + withdrawalsTable += ""; + foreach (var report in result) + { + withdrawalsTable += ""; + withdrawalsTable += $""; + withdrawalsTable += $""; + withdrawalsTable += $""; + withdrawalsTable += $""; + withdrawalsTable += ""; + foreach (var withdrawal in report.Withdrawals) + { + withdrawalsTable += ""; + withdrawalsTable += $""; + withdrawalsTable += $""; + withdrawalsTable += $""; + withdrawalsTable += $""; + withdrawalsTable += ""; + } + } + withdrawalsTable += ""; + withdrawalsTable += "
Номер счётаНомер выдачиВремя выдачиСумма
{report.AccountNumber}
{withdrawal.Id}{withdrawal.WithdrawalTime}{withdrawal.Sum}
"; + withdrawalsTable += "
"; + //title + string tables = ""; + tables += "

Отчет по счетам

"; + tables += $"
с {dateFrom.ToShortDateString()} по {dateTo.ToShortDateString()}
"; + tables += senderTransfersTable; + tables += recipientTransfersTable; + tables += withdrawalsTable; + return tables; + } + #endregion + + #region//Error + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); diff --git a/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml b/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml index 8d44ff4..6008576 100644 --- a/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml @@ -17,24 +17,36 @@ -
+
-
+
- - - - - - - - - - - -
НомерДатаСчётПереводВыдача
- \ No newline at end of file +
+ + +@section Scripts { + +} \ No newline at end of file diff --git a/Bank/BankRestApi/Controllers/ReportController.cs b/Bank/BankRestApi/Controllers/ReportController.cs index 1a09273..9cc6209 100644 --- a/Bank/BankRestApi/Controllers/ReportController.cs +++ b/Bank/BankRestApi/Controllers/ReportController.cs @@ -1,6 +1,8 @@ using BankBusinessLogic.MailWorker; using BankContracts.BindingModels; using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.ViewModels; using Microsoft.AspNetCore.Mvc; namespace BankRestApi.Controllers @@ -111,5 +113,24 @@ namespace BankRestApi.Controllers throw; } } + [HttpGet] + public List GetTransfersWithdrawals(string dateFrom, string dateTo) + { + try + { + DateTime DateFrom = DateTime.Parse(dateFrom); + DateTime DateTo = DateTime.Parse(dateTo); + return _logic.CreateReportTransfersWithdrawals(new AccountSearchModel + { + DateFrom = DateFrom, + DateTo = DateTo, + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения счетов в pdf"); + throw; + } + } } }