diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportLoad.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportLoad.cs deleted file mode 100644 index f359d10..0000000 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportLoad.cs +++ /dev/null @@ -1,36 +0,0 @@ -using BankYouBankruptContracts.BusinessLogicsContracts; -using DocumentFormat.OpenXml.ExtendedProperties; -using Org.BouncyCastle.Asn1.Ocsp; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Metadata; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptBusinessLogic.BusinessLogics -{ - public class ReportLoad : IReportLoad - { - public byte[] LoadFile(bool whoRequested) - { - string pdfFilePath; - - //если пришло true, то загружаем отчёт клиента - if (whoRequested) - { - pdfFilePath = "C:\\Users\\Programmist73\\Desktop\\Практика\\2-й курс\\4-й семестр\\CourseWork_BankYouBankrupt\\BankYouBankrupt\\BankYouBankruptRestAPI\\Отчёт_по_картам.pdf"; - } - else - { - pdfFilePath = "C:\\Users\\Programmist73\\Desktop\\Практика\\2-й курс\\4-й семестр\\CourseWork_BankYouBankrupt\\BankYouBankrupt\\BankYouBankruptRestAPI\\Отчёт_по_счетам.pdf"; - } - - byte[] bytes = System.IO.File.ReadAllBytes(pdfFilePath); - - System.IO.File.WriteAllBytes(pdfFilePath, bytes); - - return bytes; - } - } -} diff --git a/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs b/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs index bf69f31..e05164d 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs @@ -35,8 +35,8 @@ namespace BankYouBankruptСlientApp } } - //Post-запрос - public static void PostRequest(string requestUrl, T model) + //Post-запрос + public static void PostRequest(string requestUrl, T model) { var json = JsonConvert.SerializeObject(model); var data = new StringContent(json, Encoding.UTF8, "application/json"); diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index b4035b6..67e5e93 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -258,7 +258,9 @@ namespace BankYouBankruptClientApp.Controllers return Redirect("~/Home/Enter"); } - return View(); + ViewBag.DataOfClientReport = null; + + return View(); } [HttpPost] @@ -269,12 +271,14 @@ namespace BankYouBankruptClientApp.Controllers throw new Exception("Не авторизованы"); } - APIClient.PostRequest("api/Report/CreateClientReport", new ReportSupportBindingModel() + APIClient.PostRequest("api/Report/CreateClientReport", new ReportSupportBindingModel() { DateFrom = dateFrom, DateTo = dateTo }); + ViewBag.DataOfClientReport = APIClient.GetRequest($"api/Report/GetDataOfClientReport"); + return View(); } diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml index cd8ccf4..a25346c 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml @@ -1,4 +1,8 @@ -@{ +@using BankYouBankruptContracts.ViewModels; + +@model ReportClientViewModelForHTML + +@{ ViewData["Title"] = "Создание отчёта"; } @@ -24,6 +28,87 @@ -
-
+ @if (Model != null) + { +
+

Отчёт по пополнениям

+ + + + + + + + + + + @foreach (var item in Model.ReportCrediting) + { + + + + + + + } + +
+ Номер операции + + Номер карты + + Сумма + + Дата операции +
+ @Html.DisplayFor(modelItem => item.OperationId) + + @Html.DisplayFor(modelItem => item.CardNumber) + + @Html.DisplayFor(modelItem => item.SumOperation) + + @Html.DisplayFor(modelItem => item.DateComplite) +
+
+
+

Отчёт по снятиям

+ + + + + + + + + + + @foreach (var item in Model.ReportDebiting) + { + + + + + + + } + +
+ Номер операции + + Номер карты + + Сумма + + Дата операции +
+ @Html.DisplayFor(modelItem => item.OperationId) + + @Html.DisplayFor(modelItem => item.CardNumber) + + @Html.DisplayFor(modelItem => item.SumOperation) + + @Html.DisplayFor(modelItem => item.DateComplite) +
+
+ } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportLoad.cs b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportLoad.cs deleted file mode 100644 index 4c25831..0000000 --- a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportLoad.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptContracts.BusinessLogicsContracts -{ - public interface IReportLoad - { - byte[] LoadFile(bool whoRequested); - } -} diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs index cde358e..fbff12f 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs @@ -18,29 +18,29 @@ namespace BankYouBankruptRestAPI.Controllers { private readonly ILogger _logger; - //private readonly IReportCashierLogic _reportCashierLogic; - private readonly IReportClientLogic _reportClientLogic; private readonly IReportCashierLogic _reportCashierLogic; - private readonly IReportLoad _reportLoad; + //хранят данные для отображения отчёта на вебе + private ReportClientViewModelForHTML _reportClientViewModelForHTML; - public ReportController(ILogger logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic, IReportLoad reportLoad) + private ReportCashierViewModelForHTML _reportCashierViewModelForHTML; + + public ReportController(ILogger logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic) { _logger = logger; _reportClientLogic = reportClientLogic; _reportCashierLogic = reportCashierLogic; - _reportLoad = reportLoad; } //метод генерации отчёта за период по картам клиента [HttpPost] - public ReportClientViewModelForHTML CreateClientReport(ReportSupportBindingModel model) + public void CreateClientReport(ReportSupportBindingModel model) { try { - return _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel + _reportClientViewModelForHTML = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel { FileName = "Отчёт_по_картам.pdf", DateFrom = model.DateFrom, @@ -56,11 +56,11 @@ namespace BankYouBankruptRestAPI.Controllers //метод генерации отчёта по всем счетм клиентов [HttpPost] - public ReportCashierViewModelForHTML CreateCashierReport(ReportSupportBindingModel model) + public void CreateCashierReport(ReportSupportBindingModel model) { try { - return _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel + _reportCashierViewModelForHTML = _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel { FileName = "Отчёт_по_счетам.pdf", ClientId = model.ClientId, @@ -74,5 +74,78 @@ namespace BankYouBankruptRestAPI.Controllers throw; } } + + //передача данных из отчёта клиента + [HttpGet] + public ReportClientViewModelForHTML GetDataOfClientReport() + { + try + { + return _reportClientViewModelForHTML; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + //передача данных из отчёта кассира + [HttpGet] + public ReportCashierViewModelForHTML GetDataOfCashierReport() + { + try + { + return _reportCashierViewModelForHTML; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + /* + //метод генерации отчёта за период по картам клиента + [HttpPost] + public void CreateClientReport(ReportSupportBindingModel model) + { + try + { + _reportClientViewModelForHTML = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel + { + FileName = "Отчёт_по_картам.pdf", + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + //метод генерации отчёта по всем счетм клиентов + [HttpPost] + public void CreateCashierReport(ReportSupportBindingModel model) + { + try + { + _reportCashierViewModelForHTML = _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel + { + FileName = "Отчёт_по_счетам.pdf", + ClientId = model.ClientId, + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + */ } } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs index ff42f0f..4592562 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs @@ -34,14 +34,11 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddTransient(); - -//для отправки файла в приложение -builder.Services.AddTransient(); +builder.Services.AddSingleton(); builder.Services.AddTransient(); -builder.Services.AddSingleton(); +builder.Services.AddTransient(); //теперь общий builder.Services.AddTransient(); diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf index 2ad1474..818a3b9 100644 Binary files a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf differ