Готовый отчёт для клиента.

This commit is contained in:
Programmist73 2023-05-19 02:18:52 +04:00
parent a46290e4d4
commit 79cc787ebf
4 changed files with 29 additions and 11 deletions

View File

@ -50,5 +50,25 @@ namespace BankYouBankruptСlientApp
throw new Exception(result); throw new Exception(result);
} }
} }
//Post-запрос для получения данных
public static T? PostRequestReport<T, U>(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<T>(result);
}
else
{
throw new Exception(result);
}
}
} }
} }

View File

@ -253,8 +253,6 @@ namespace BankYouBankruptClientApp.Controllers
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
ViewBag.DataOfClientReport = null;
return View(); return View();
} }
@ -266,15 +264,13 @@ namespace BankYouBankruptClientApp.Controllers
throw new Exception("Не авторизованы"); throw new Exception("Не авторизованы");
} }
APIClient.PostRequest("api/Report/CreateClientReport", new ReportSupportBindingModel() //ViewBag.DataOfClientReport = APIClient.GetRequest<ReportClientViewModelForHTML>($"api/Report/GetDataOfClientReport");
return View(APIClient.PostRequestReport<ReportClientViewModelForHTML, ReportSupportBindingModel>("api/Report/CreateClientReport", new ReportSupportBindingModel()
{ {
DateFrom = dateFrom, DateFrom = dateFrom,
DateTo = dateTo DateTo = dateTo
}); }));
ViewBag.DataOfClientReport = APIClient.GetRequest<ReportClientViewModelForHTML>($"api/Report/GetDataOfClientReport");
return View();
} }
#endregion #endregion

View File

@ -36,16 +36,18 @@ namespace BankYouBankruptRestAPI.Controllers
//метод генерации отчёта за период по картам клиента //метод генерации отчёта за период по картам клиента
[HttpPost] [HttpPost]
public void CreateClientReport(ReportSupportBindingModel model) public ReportClientViewModelForHTML CreateClientReport(ReportSupportBindingModel model)
{ {
try try
{ {
_reportClientViewModelForHTML = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel var result = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel
{ {
FileName = "Отчёт_поартам.pdf", FileName = "Отчёт_поартам.pdf",
DateFrom = model.DateFrom, DateFrom = model.DateFrom,
DateTo = model.DateTo DateTo = model.DateTo
}); });
return result;
} }
catch (Exception ex) catch (Exception ex)
{ {