From 9068da1cac4cccf204d331a05d543a9e0ad46614 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Mon, 27 May 2024 01:22:25 +0400 Subject: [PATCH] start adding pdf report --- .../BindingModels/ReportBindingModel.cs | 1 + .../BusinessLogicsContracts/IReportLogic.cs | 4 ++-- .../BusinessLogicsContracts/IRequestLogic.cs | 4 +--- .../Controllers/HomeController.cs | 23 ++++++++++++++++--- .../TransfersWithdrawalsListReport.cshtml | 22 +++++++++--------- .../Controllers/ReportController.cs | 13 +++++++++++ 6 files changed, 48 insertions(+), 19 deletions(-) diff --git a/Bank/BankContracts/BindingModels/ReportBindingModel.cs b/Bank/BankContracts/BindingModels/ReportBindingModel.cs index 532aafa..c962348 100644 --- a/Bank/BankContracts/BindingModels/ReportBindingModel.cs +++ b/Bank/BankContracts/BindingModels/ReportBindingModel.cs @@ -13,5 +13,6 @@ namespace BankContracts.BindingModels public DateTime? DateTo { get; set; } public List? SelectedAccountIds { get; set; } public List? SelectedCardIds { get; set; } + public string? Email { get; set; } } } diff --git a/Bank/BankContracts/BusinessLogicsContracts/IReportLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IReportLogic.cs index 8247263..0138bd3 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/IReportLogic.cs @@ -4,6 +4,7 @@ using BankContracts.ViewModels; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -21,7 +22,6 @@ namespace BankContracts.BusinessLogicsContracts void SaveTransfersToExcelFile(ReportBindingModel model); void SaveOperationsRequestsToPdfFile(ReportBindingModel model); void SaveTransfersWithdrawalsToPdfFile(ReportBindingModel model); - - + void SendTransfersWithdrawalsToEmail(ReportBindingModel model); } } diff --git a/Bank/BankContracts/BusinessLogicsContracts/IRequestLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IRequestLogic.cs index 9be7e47..7a9a5b3 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/IRequestLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/IRequestLogic.cs @@ -16,8 +16,6 @@ namespace BankContracts.BusinessLogicsContracts bool Create(RequestBindingModel model); bool Update(RequestBindingModel model); bool Delete(RequestBindingModel model); - //todo методы смены статуса - //bool DeclineRequest(RequestBindingModel model); - //bool SatisfyRequest(RequestBindingModel model); + } } diff --git a/Bank/BankManagersClientApp/Controllers/HomeController.cs b/Bank/BankManagersClientApp/Controllers/HomeController.cs index b0fea54..1555cdf 100644 --- a/Bank/BankManagersClientApp/Controllers/HomeController.cs +++ b/Bank/BankManagersClientApp/Controllers/HomeController.cs @@ -512,10 +512,27 @@ namespace BankManagersClientApp.Controllers } return View(); } - #endregion - #region//Error - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [HttpPost] + public void TransfersWithdrawalsListReport(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest("api/report/sendtransferswithdrawalstoemail", new ReportBindingModel + { + FileName = "C:\\Users\\user\\Downloads\\TransfersWithdrawalsList.pdf", + DateFrom = dateFrom, + DateTo = dateTo, + Email = APIClient.Client.Email, + }); + Response.Redirect("TransfersWithdrawalsListReport"); + } + #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 42df840..8422020 100644 --- a/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml @@ -2,22 +2,30 @@ ViewData["Title"] = "TransfersWithdrawalsListReport"; }
-

Список счетов с расшифровкой по переводам и выдачам

+

Список счетов с расшифровкой по переводам и выдачам по периоду

@{
Начальная дата:
- +
Конечная дата:
- +
+
+
+
+
+
+
+
+
@@ -30,13 +38,5 @@
-
-
-
-
-
-
-
-
}
\ No newline at end of file diff --git a/Bank/BankRestApi/Controllers/ReportController.cs b/Bank/BankRestApi/Controllers/ReportController.cs index 5c4401c..002e82f 100644 --- a/Bank/BankRestApi/Controllers/ReportController.cs +++ b/Bank/BankRestApi/Controllers/ReportController.cs @@ -70,5 +70,18 @@ namespace BankRestApi.Controllers throw; } } + [HttpPost] + public void SendTransfersWithdrawalsToEmail(ReportBindingModel model) + { + try + { + _logic.SendTransfersWithdrawalsToEmail(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения переводов в ворд"); + throw; + } + } } }