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) + + +
+ } +