From 0d12590f78e0b63b719a5580ade1a0f3d64b2ac6 Mon Sep 17 00:00:00 2001 From: "ityurner02@mail.ru" Date: Thu, 18 May 2023 23:13:51 +0400 Subject: [PATCH] =?UTF-8?q?Word/Excel=20=D0=BE=D1=82=D1=87=D0=B5=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/Home/Reports.cshtml | 2 +- .../Controllers/HomeController.cs | 30 +++++++++++++++- .../Views/Home/LessonSetting.cshtml | 2 +- .../Views/Home/Reports.cshtml | 23 ++++++++++++ .../Views/Home/_DiyListPartial.cshtml | 35 +++++++++++++++++++ 5 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/Reports.cshtml create mode 100644 SchoolAgainStudy/TeacherWebClient/Views/Home/_DiyListPartial.cshtml diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/Reports.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/Reports.cshtml index d06a709..bbc2832 100644 --- a/SchoolAgainStudy/StudentWebClient/Views/Home/Reports.cshtml +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/Reports.cshtml @@ -2,7 +2,7 @@ ViewData["Title"] = "Report"; }
- diff --git a/SchoolAgainStudy/TeacherWebClient/Controllers/HomeController.cs b/SchoolAgainStudy/TeacherWebClient/Controllers/HomeController.cs index a238d93..904ebfb 100644 --- a/SchoolAgainStudy/TeacherWebClient/Controllers/HomeController.cs +++ b/SchoolAgainStudy/TeacherWebClient/Controllers/HomeController.cs @@ -18,7 +18,8 @@ namespace TeacherWebClient.Controllers private readonly ITaskLogic _task; private readonly IMaterialLogic _material; private readonly ITeacherLogic _teacher; - public HomeController(ILogger logger, IProductLogic product, ILessonLogic lesson, ITaskLogic task, IMaterialLogic material, ITeacherLogic teacher) + private readonly IReportLogic _report; + public HomeController(ILogger logger, IProductLogic product, ILessonLogic lesson, ITaskLogic task, IMaterialLogic material, ITeacherLogic teacher, IReportLogic report) { _logger = logger; _product = product; @@ -26,6 +27,7 @@ namespace TeacherWebClient.Controllers _task = task; _material = material; _teacher = teacher; + _report = report; } [HttpGet] @@ -417,5 +419,31 @@ namespace TeacherWebClient.Controllers }); Response.Redirect("/Home/Tasks"); } + public IActionResult Reports() + { + var list = _material.ReadList(new MaterialSearchModel { TeacherId = APIClient.Teacher.Id }); + var simpMaterial = list.Select(x => new { MaterialId = x.Id, MaterialName = x.Title }); + ViewBag.Materials = new MultiSelectList(simpMaterial, "MaterialId", "MaterialName"); + return View(); + } + + public IActionResult GetPartial(int[] materials, string mode) + { + var list = materials.Select(x => _material.ReadElement(new MaterialSearchModel { Id = x })).ToList(); + if (mode.Equals("Excel")) + { + _report.SaveDiyMaterialToExcelFile + (new ReportBindingModel { FileName = $"C:\\Университет\\2 курс\\4 семестр\\РПП\\Курсач РПП\\Reports\\{APIClient.Teacher.Name}-{DateTime.Now.ToString("dd/MM/yyyy")}.xlsx", Materials = list, TeacherId = APIClient.Teacher.Id }); + + } + else + { + _report.SaveDiyMaterialToWordFile + (new ReportBindingModel { FileName = $"C:\\Университет\\2 курс\\4 семестр\\РПП\\Курсач РПП\\Reports\\{APIClient.Teacher.Name}-{DateTime.Now.ToString("dd/MM/yyyy")}.docx", Materials = list, TeacherId = APIClient.Teacher.Id }); + + } + var items = _report.GetDiyMaterial(new ReportBindingModel { Materials = list, TeacherId = APIClient.Teacher.Id }); + return PartialView("_DiyListPartial", items); + } } } \ No newline at end of file diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/LessonSetting.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/LessonSetting.cshtml index bab737f..7b04241 100644 --- a/SchoolAgainStudy/TeacherWebClient/Views/Home/LessonSetting.cshtml +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/LessonSetting.cshtml @@ -24,7 +24,7 @@
Изделие:
- +
diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/Reports.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/Reports.cshtml new file mode 100644 index 0000000..5d307ea --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/Reports.cshtml @@ -0,0 +1,23 @@ +@{ + ViewData["Title"] = "Report"; +} + + +
+
Материалы:
+
+ @Html.ListBox("materials", (MultiSelectList)ViewBag.Materials) +
+
+
+
+
+
+ +
+ @section scripts{ + + } diff --git a/SchoolAgainStudy/TeacherWebClient/Views/Home/_DiyListPartial.cshtml b/SchoolAgainStudy/TeacherWebClient/Views/Home/_DiyListPartial.cshtml new file mode 100644 index 0000000..1fde12a --- /dev/null +++ b/SchoolAgainStudy/TeacherWebClient/Views/Home/_DiyListPartial.cshtml @@ -0,0 +1,35 @@ +@using SchoolAgainStudyContracts.ViewModel; +@model List + + +
+ @{ + + + + + + + + + + + @foreach (var item in Model) + { + + + + + } + +
+ Название + + Материалы +
+ @Html.DisplayFor(modelItem => item.Title) + + +
+ } +