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