From f13a3e428c59892e62845207c32f9a60c36c971a Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 18 May 2023 00:47:56 +0400 Subject: [PATCH] Check commit. --- .../BusinessLogics/ReportClientLogic.cs | 2 +- .../OfficePackage/AbstractSaveToPdfCashier.cs | 8 ++--- .../OfficePackage/AbstractSaveToPdfClient.cs | 6 ++-- .../{PdfInfoClient.cs => PdfInfo.cs} | 7 +++-- .../OfficePackage/Implements/SaveToPdf.cs | 4 +-- .../Controllers/HomeController.cs | 23 +++++++++++--- .../Views/Home/CreateReport.cshtml | 30 ++++++++++++++++--- .../Views/Shared/_Layout.cshtml | 2 +- .../Enums/TypeOperationEnum.cs | 1 + .../Controllers/AccountController.cs | 1 - 10 files changed, 62 insertions(+), 22 deletions(-) rename BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/{PdfInfoClient.cs => PdfInfo.cs} (83%) diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs index 4e45533..30eef2d 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs @@ -84,7 +84,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics //отчёт в формате PDF для клиента public void SaveClientReportToPdfFile(ReportBindingModel model) { - _saveToPdf.CreateDoc(new PdfInfoClient + _saveToPdf.CreateDoc(new PdfInfo { FileName = model.FileName, Title = "Отчёт по операциям с картой", diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs index d0d4fae..8cfd443 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfCashier.cs @@ -11,7 +11,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage public abstract class AbstractSaveToPdfCashier { //публичный метод создания документа. Описание методов ниже - public void CreateDoc(PdfInfoClient info) + public void CreateDoc(PdfInfo info) { CreatePdf(info); @@ -38,7 +38,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage ParagraphAlignment = PdfParagraphAlignmentType.Center }); - foreach (var report in info.ReportAccounts) + foreach (var report in info.Accounts) { CreateRow(new PdfRowParameters { @@ -54,7 +54,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage } /// Создание pdf-файла - protected abstract void CreatePdf(PdfInfoClient info); + protected abstract void CreatePdf(PdfInfo info); /// Создание параграфа с текстом protected abstract void CreateParagraph(PdfParagraph paragraph); @@ -66,6 +66,6 @@ namespace BankYouBankruptBusinessLogic.OfficePackage protected abstract void CreateRow(PdfRowParameters rowParameters); /// Сохранение файла - protected abstract void SavePdf(PdfInfoClient info); + protected abstract void SavePdf(PdfInfo info); } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs index 3d3b62d..b4bc8dc 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToPdfClient.cs @@ -11,7 +11,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage public abstract class AbstractSaveToPdfClient { //публичный метод создания документа. Описание методов ниже - public void CreateDoc(PdfInfoClient info) + public void CreateDoc(PdfInfo info) { CreatePdf(info); @@ -66,7 +66,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage } /// Создание pdf-файла - protected abstract void CreatePdf(PdfInfoClient info); + protected abstract void CreatePdf(PdfInfo info); /// Создание параграфа с текстом protected abstract void CreateParagraph(PdfParagraph paragraph); @@ -78,6 +78,6 @@ namespace BankYouBankruptBusinessLogic.OfficePackage protected abstract void CreateRow(PdfRowParameters rowParameters); /// Сохранение файла - protected abstract void SavePdf(PdfInfoClient info); + protected abstract void SavePdf(PdfInfo info); } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfoClient.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs similarity index 83% rename from BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfoClient.cs rename to BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 5f63c6f..7cf9432 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfoClient.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels { //общая информация по pdf файлу - public class PdfInfoClient + public class PdfInfo { public string FileName { get; set; } = string.Empty; @@ -23,5 +23,8 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels //перечень заказов за указанный период для вывода/сохранения public List ReportDebiting { get; set; } = new(); - } + + //перечень счетов для отчёта кассира + public List Accounts { get; set; } = new(); + } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index d7bfa9e..20d671a 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -44,7 +44,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.Implements style.Font.Bold = true; } - protected override void CreatePdf(PdfInfoClient info) + protected override void CreatePdf(PdfInfo info) { //создаём документ _document = new Document(); @@ -117,7 +117,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.Implements } } - protected override void SavePdf(PdfInfoClient info) + protected override void SavePdf(PdfInfo info) { var renderer = new PdfDocumentRenderer(true) { diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index 4484429..7824189 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -209,7 +209,6 @@ namespace BankYouBankruptClientApp.Controllers return Redirect("~/Home/Enter"); } - ViewBag.Cards = APIClient.GetRequest>($"api/Card/GetAllCards").Select(x => new ClientSelectViewModel { Id = x.Id, @@ -240,18 +239,32 @@ namespace BankYouBankruptClientApp.Controllers #endregion - #region Получение отчёта + #region Получение отчёта PDF [HttpGet] public IActionResult CreateReport() { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + return View(); } [HttpPost] - public void CreateReport(DateTime DateFrom, DateTime DateTo) + public void CreateReport(DateTime dateFrom, DateTime dateTo) { + if (APIClient.Client == null) + { + throw new Exception("Не авторизованы"); + } + APIClient.PostRequest("/api/Report/CreateClientReport", new ReportBindingModel() + { + DateFrom = dateFrom, + DateTo = dateTo + }); } #endregion @@ -283,6 +296,7 @@ namespace BankYouBankruptClientApp.Controllers } List cardList = cards.Where(x => x.IsChecked).Select(x => x.Id).ToList(); + List creditings = APIClient.GetRequest>($"api/Client/getUsersCreditings?userId={APIClient.Client.Id}") .Where(x => cardList.Contains(x.CardId)).Select(x => new ReportViewModel() { Id = x.Id, @@ -294,6 +308,7 @@ namespace BankYouBankruptClientApp.Controllers Sum = x.Sum, TypeOperation = TypeOperationEnum.Пополнение }).ToList(); + List debitings = APIClient.GetRequest>($"api/Client/getUsersDebitings?userId={APIClient.Client.Id}") .Where(x => cardList.Contains(x.CardId)).Select(x => new ReportViewModel() { @@ -306,13 +321,13 @@ namespace BankYouBankruptClientApp.Controllers Sum = x.Sum, TypeOperation = TypeOperationEnum.Снятие }).ToList(); + List result = creditings.Concat(debitings).OrderBy(x => x.DateOpen).ToList(); return View(new ReportClientCardsViewModel() { Cards = cards, Operations = result, - }); } } diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml index e1dd794..2351ed3 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml @@ -1,5 +1,27 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ -@{ +@{ + ViewData["Title"] = "Создание отчёта"; } + +
+

Отчёт по картам за выбранный период

+
+
+
+
Дата начала периода:
+
+ +
+
+
+
Дата конца периода:
+
+ +
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml index cfd83bd..05efbac 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml @@ -38,7 +38,7 @@ Отчет по картам } diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Enums/TypeOperationEnum.cs b/BankYouBankrupt/BankYouBankruptDataModels/Enums/TypeOperationEnum.cs index 1356e76..da6e32e 100644 --- a/BankYouBankrupt/BankYouBankruptDataModels/Enums/TypeOperationEnum.cs +++ b/BankYouBankrupt/BankYouBankruptDataModels/Enums/TypeOperationEnum.cs @@ -9,6 +9,7 @@ namespace BankYouBankruptDataModels.Enums public enum TypeOperationEnum { Снятие = 1, + Пополнение = 2 } } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs index c144096..6dd98b7 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs @@ -198,7 +198,6 @@ namespace BankYouBankruptRestApi.Controllers { try { - bool flag =_accountLogic.ChangeBalance(new AccountSearchModel { Id = CashWithdrawal.AccountId