diff --git a/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs b/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs index e05164d..06bf9e6 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs @@ -50,5 +50,25 @@ namespace BankYouBankruptСlientApp throw new Exception(result); } } - } + + //Post-запрос для получения данных + public static T? PostRequestReport(string requestUrl, U model) + { + var json = JsonConvert.SerializeObject(model); + var data = new StringContent(json, Encoding.UTF8, "application/json"); + + var response = _client.PostAsync(requestUrl, data); + + var result = response.Result.Content.ReadAsStringAsync().Result; + + if (response.Result.IsSuccessStatusCode) + { + return JsonConvert.DeserializeObject(result); + } + else + { + throw new Exception(result); + } + } + } } diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index 8a6aef4..9a6829f 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -253,8 +253,6 @@ namespace BankYouBankruptClientApp.Controllers return Redirect("~/Home/Enter"); } - ViewBag.DataOfClientReport = null; - return View(); } @@ -266,15 +264,13 @@ namespace BankYouBankruptClientApp.Controllers throw new Exception("Не авторизованы"); } - APIClient.PostRequest("api/Report/CreateClientReport", new ReportSupportBindingModel() + //ViewBag.DataOfClientReport = APIClient.GetRequest($"api/Report/GetDataOfClientReport"); + + return View(APIClient.PostRequestReport("api/Report/CreateClientReport", new ReportSupportBindingModel() { DateFrom = dateFrom, DateTo = dateTo - }); - - ViewBag.DataOfClientReport = APIClient.GetRequest($"api/Report/GetDataOfClientReport"); - - return View(); + })); } #endregion diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs index fbff12f..470b835 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs @@ -36,16 +36,18 @@ namespace BankYouBankruptRestAPI.Controllers //метод генерации отчёта за период по картам клиента [HttpPost] - public void CreateClientReport(ReportSupportBindingModel model) + public ReportClientViewModelForHTML CreateClientReport(ReportSupportBindingModel model) { try { - _reportClientViewModelForHTML = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel + var result = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel { FileName = "Отчёт_по_картам.pdf", DateFrom = model.DateFrom, DateTo = model.DateTo }); + + return result; } catch (Exception ex) { diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf index 818a3b9..13f6aad 100644 Binary files a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf differ