From 53c6b8fb7637bd1b85373c025b58671309797161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BE=D0=BB=D0=BE=D0=B4=D1=8F?= Date: Thu, 18 May 2023 19:23:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BE=D1=82=D1=87=D0=B5=D1=82=D1=8B=20=D0=92?= =?UTF-8?q?=D0=BE=D1=80=D0=B4/=D0=AD=D0=BA=D1=81=D0=B5=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 33 ++++++++++++++--- .../Views/Home/Reports.cshtml | 24 ++++++++++++- .../Views/Home/_LessonListPartial.cshtml | 35 +++++++++++++++++++ 3 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 SchoolAgainStudy/StudentWebClient/Views/Home/_LessonListPartial.cshtml diff --git a/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs b/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs index 1685c38..b8ad20e 100644 --- a/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs +++ b/SchoolAgainStudy/StudentWebClient/Controllers/HomeController.cs @@ -20,7 +20,9 @@ namespace StudentWebClient.Controllers private readonly IProductLogic _product; private readonly IInterestLogic _interest; private readonly IStudentLogic _student; - public HomeController(ILogger logger, IDiyLogic diy, IProductLogic product , ITaskLogic task , IInterestLogic interest, IStudentLogic student) + private readonly IReportLogic _report; + public HomeController(ILogger logger, IDiyLogic diy, + IProductLogic product , ITaskLogic task , IInterestLogic interest, IStudentLogic student, IReportLogic report) { _logger = logger; _diy = diy; @@ -28,6 +30,7 @@ namespace StudentWebClient.Controllers _task = task; _interest = interest; _student = student; + _report = report; } public IActionResult Index() @@ -70,7 +73,7 @@ namespace StudentWebClient.Controllers { Id = APIClient.Student.Id, Name = name, - Email = login, + Email = email, Password = password, Login = login, Class = scClass @@ -119,7 +122,7 @@ namespace StudentWebClient.Controllers _student.Create( new StudentBindingModel { Name = name, - Email = login, + Email = email, Password = password, Login = login, Class = scClass @@ -420,8 +423,30 @@ namespace StudentWebClient.Controllers } public IActionResult Reports() { + var list = _interest.ReadList(new InterestSearchModel { StudentId = APIClient.Student.Id }); + var simpInterest = list.Select(x => new { InterestId = x.Id, InterestName = x.Title }); + ViewBag.Interests = new MultiSelectList(simpInterest, "InterestId", "InterestName"); return View(); } - + + public IActionResult GetPartial(int[] interests, string mode) + { + var list = interests.Select(x => _interest.ReadElement(new InterestSearchModel { Id = x })).ToList(); + if (mode.Equals("Excel")) + { + _report.SaveInterestLessonToExcelFile + (new ReportBindingModel { FileName = $"C:\\Users\\Вова\\Documents\\Учеба\\Reports\\{APIClient.Student.Name}-{DateTime.Now.ToString("dd/MM/yyyy")}.xlsx", Interests = list, StudentId = APIClient.Student.Id }); + + } + else + { + _report.SaveInterestLessonToWordFile + (new ReportBindingModel { FileName = $"C:\\Users\\Вова\\Documents\\Учеба\\Reports\\{APIClient.Student.Name}-{DateTime.Now.ToString("dd/MM/yyyy")}.docx", Interests = list, StudentId = APIClient.Student.Id }); + + } + var items = _report.GetInterestLesson(new ReportBindingModel { Interests = list, StudentId = APIClient.Student.Id}); + return PartialView("_LessonListPartial", items); + } + } } \ No newline at end of file diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/Reports.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/Reports.cshtml index 5f28270..d06a709 100644 --- a/SchoolAgainStudy/StudentWebClient/Views/Home/Reports.cshtml +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/Reports.cshtml @@ -1 +1,23 @@ - \ No newline at end of file +@{ + ViewData["Title"] = "Report"; +} +
+ +
+
Интересы:
+
+ @Html.ListBox("interests", (MultiSelectList)ViewBag.Interests) +
+
+
+
+
+
+
+
+@section scripts{ + +} \ No newline at end of file diff --git a/SchoolAgainStudy/StudentWebClient/Views/Home/_LessonListPartial.cshtml b/SchoolAgainStudy/StudentWebClient/Views/Home/_LessonListPartial.cshtml new file mode 100644 index 0000000..ac82ea9 --- /dev/null +++ b/SchoolAgainStudy/StudentWebClient/Views/Home/_LessonListPartial.cshtml @@ -0,0 +1,35 @@ +@using SchoolAgainStudyContracts.ViewModel; +@model List + + +
+ @{ + + + + + + + + + + + @foreach (var item in Model) + { + + + + + } + +
+ Название + + Интересы +
+ @Html.DisplayFor(modelItem => item.Title) + + +
+ } +
\ No newline at end of file