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

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,22 +199,21 @@ 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]
public void ReportDisciplines(string type, DateOnly dateFrom, DateOnly dateTo) public void ReportDisciplines(string type, DateOnly dateFrom, DateOnly dateTo)
@ -267,7 +266,22 @@ namespace UniversityClientApp.Controllers
return View("ReportDisciplines", reportData); return View("ReportDisciplines", reportData);
} }
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
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)]
public IActionResult Error() public IActionResult Error()
{ {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });