Егор финал репортов ВСЕХ

This commit is contained in:
GokaPek 2024-05-30 02:14:15 +04:00
parent 5e53d3c1d5
commit 495bafb4e3

View File

@ -183,7 +183,7 @@ namespace UniversityClientApp.Controllers
} }
[HttpPost] [HttpPost]
public void Report(string type) public IActionResult Report(string type)
{ {
if (APIStorekeeper.Client == null) if (APIStorekeeper.Client == null)
{ {
@ -199,21 +199,20 @@ namespace UniversityClientApp.Controllers
{ {
APIStorekeeper.PostRequest("api/teacher/loadreporttoword", new ReportBindingModel APIStorekeeper.PostRequest("api/teacher/loadreporttoword", new ReportBindingModel
{ {
FileName = $"C:\\Users\\{Environment.UserName}\\Desktop\\TeachersAndStudents{Environment.TickCount}.docx" FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\TeachersAndStudents.docx"
}); });
Response.Redirect("Report"); return GetWordFile();
return;
} }
if (type == "xlsx") if (type == "xlsx")
{ {
APIStorekeeper.PostRequest("api/teacher/loadreporttoexcel", new ReportBindingModel APIStorekeeper.PostRequest("api/teacher/loadreporttoexcel", new ReportBindingModel
{ {
FileName = $"C:\\Users\\{Environment.UserName}\\Desktop\\TeachersAndStudents{Environment.TickCount}.xlsx" FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\TeachersAndStudents.xlsx"
}); });
Response.Redirect("Report"); return GetExcelFile();
return;
} }
return Redirect("Report");
} }
[HttpPost] [HttpPost]
@ -267,6 +266,21 @@ namespace UniversityClientApp.Controllers
return View("ReportDisciplines", reportData); return View("ReportDisciplines", reportData);
} }
public IActionResult GetWordFile()
{
return PhysicalFile($"C:\\ÂðåìåííûåÎò÷¸òû\\TeachersAndStudents.xlsx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"TeachersAndStudents.docx");
}
public IActionResult GetExcelFile()
{
return PhysicalFile($"C:\\ÂðåìåííûåÎò÷¸òû\\TeachersAndStudents.xlsx",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"TeachersAndStudents.xlsx");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() public IActionResult Error()
{ {