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