From 93693e13823433223385be0ba81006b115fdd3a6 Mon Sep 17 00:00:00 2001 From: abazov73 <92822431+abazov73@users.noreply.github.com> Date: Sat, 20 May 2023 02:48:45 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D1=81=D0=BC=D0=BE=D1=82?= =?UTF-8?q?=D1=80=20=D0=BE=D1=82=D1=87=D1=91=D1=82=D0=B0=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20"=D0=97=D0=B0=D0=BA=D0=B0=D0=B7=D1=87=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0"=20=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5=20+=20?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20PdfInfo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OfficePackage/AbstractSaveToPdf.cs | 5 ++ .../OfficePackage/HelperModels/PdfInfo.cs | 2 +- .../OperatorApp/Controllers/HomeController.cs | 18 +++- .../Views/Home/TransfersReport.cshtml | 2 +- Bank/OperatorApp/Views/Home/ViewReport.cshtml | 88 +++++++++++++++++++ 5 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 Bank/OperatorApp/Views/Home/ViewReport.cshtml diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index e76e7b2..555a904 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -12,6 +12,11 @@ namespace BankBusinessLogic.OfficePackage { public MemoryStream CreateOperatorDoc(PdfInfo info) { + if (info.Transfers == null) + { + throw new ArgumentNullException("Данные для отчёта отсутсвуют!", nameof(info.Transfers)); + } + CreatePdf(info); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); diff --git a/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 9c9be5b..fc8f070 100644 --- a/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/Bank/BankBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -17,6 +17,6 @@ namespace BankBusinessLogic.OfficePackage.HelperModels public DateTime DateTo { get; set; } - public List Transfers { get; set; } = new(); + public List? Transfers { get; set; } = new(); } } diff --git a/Bank/OperatorApp/Controllers/HomeController.cs b/Bank/OperatorApp/Controllers/HomeController.cs index fd8b27f..38d95c0 100644 --- a/Bank/OperatorApp/Controllers/HomeController.cs +++ b/Bank/OperatorApp/Controllers/HomeController.cs @@ -101,12 +101,14 @@ namespace OperatorApp.Controllers { if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) { - throw new Exception("Введите логин и пароль"); + Response.WriteAsync($""); + return; } APIClient.Operator = _operatorLogic.ReadElement(new OperatorSearchModel { Login = login, Password = password }); if (APIClient.Operator == null) { - throw new Exception("Неверный логин/пароль"); + Response.WriteAsync($""); + return; } Response.Redirect("Index"); } @@ -329,5 +331,17 @@ namespace OperatorApp.Controllers Response.Redirect("/"); } } + + public IActionResult ViewReport(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.Operator == null) + { + Response.WriteAsync($""); + return Redirect("/Home/Enter"); + } + ViewBag.DateFrom = dateFrom.ToShortDateString(); + ViewBag.DateTo = dateTo.ToShortDateString(); + return View(_reportLogic.GetTransferPurchase(new ReportBindingModel { DateFrom=dateFrom, DateTo = dateTo })); + } } } \ No newline at end of file diff --git a/Bank/OperatorApp/Views/Home/TransfersReport.cshtml b/Bank/OperatorApp/Views/Home/TransfersReport.cshtml index 806205b..b91993c 100644 --- a/Bank/OperatorApp/Views/Home/TransfersReport.cshtml +++ b/Bank/OperatorApp/Views/Home/TransfersReport.cshtml @@ -7,7 +7,7 @@

Создание отчёта

-
+
C:
diff --git a/Bank/OperatorApp/Views/Home/ViewReport.cshtml b/Bank/OperatorApp/Views/Home/ViewReport.cshtml new file mode 100644 index 0000000..eb527fa --- /dev/null +++ b/Bank/OperatorApp/Views/Home/ViewReport.cshtml @@ -0,0 +1,88 @@ +@using BankContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "View Report"; +} + +
+

Отчёт о зачислениях

+

C @ViewBag.DateFrom по @ViewBag.DateTo

+
+ + +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + + + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + @foreach (var purchase in item.Purchases){ + + + + + + + + + } + } + +
+ Номер зачисления + + Дата зачисления + + Номер закупки + + Сумма + + Валюта + + Дата закупки +
+ Зачисление №@item.TransferId + + @Html.DisplayFor(modelItem => item.TransferDate) + + + + +
+ + + Закупка №@purchase.Id + + @Html.DisplayFor(modelItem => purchase.Amount) + + @Html.DisplayFor(modelItem => purchase.CurrencyName) + + @Html.DisplayFor(modelItem => purchase.PurchaseDate) +
+ } +
\ No newline at end of file