From 974d8946ee77289402d1d32dc3480f1349a4d9ec Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Mon, 27 May 2024 17:32:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=81=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 30 +++++++++- .../Views/Home/Index.cshtml | 23 +++---- .../Views/Home/InfoPlanOfStudy.cshtml | 30 ++++++++++ .../Views/Home/PlanOfStudys.cshtml | 60 ------------------- .../Views/Home/Students.cshtml | 33 ++++++---- .../Implements/PlanOfStudyStorage.cs | 14 ++++- .../UniversityDatabase.cs | 2 +- .../Controllers/PlanOfStudysController.cs | 4 +- 8 files changed, 105 insertions(+), 91 deletions(-) create mode 100644 University/UniversityClientAppWorker/Views/Home/InfoPlanOfStudy.cshtml delete mode 100644 University/UniversityClientAppWorker/Views/Home/PlanOfStudys.cshtml diff --git a/University/UniversityClientAppWorker/Controllers/HomeController.cs b/University/UniversityClientAppWorker/Controllers/HomeController.cs index 9cec5cf..efdbbe8 100644 --- a/University/UniversityClientAppWorker/Controllers/HomeController.cs +++ b/University/UniversityClientAppWorker/Controllers/HomeController.cs @@ -44,7 +44,33 @@ namespace UniversityClientAppWorker.Controllers }); Response.Redirect("Index"); } - [HttpGet] + [HttpPost] + public void DeletePlanOfStudy(int id) + { + if (id == 0) + { + throw new Exception("id 0"); + } + APIClient.PostRequest("api/planofstudys/deleteplanofstudy", new PlanOfStudyBindingModel + { + Id = id + }); + Response.Redirect("Index"); + } + [HttpPost] + public void UpdatePlanOfStudy(int id) + { + if (id == 0) + { + throw new Exception("id 0"); + } + APIClient.PostRequest("api/planofstudys/updateplanofstudy", new PlanOfStudyBindingModel + { + Id = id + }); + Response.Redirect("Index"); + } + [HttpGet] public IActionResult Privacy() { if (APIClient.User == null) @@ -94,7 +120,7 @@ namespace UniversityClientAppWorker.Controllers { return Redirect("~/Home/Enter"); } - return View(); + return View(APIClient.GetRequest>($"api/student/getstudents?userId={APIClient.User.Id}")); } [HttpGet] public IActionResult Enter() diff --git a/University/UniversityClientAppWorker/Views/Home/Index.cshtml b/University/UniversityClientAppWorker/Views/Home/Index.cshtml index bc8fa47..dbd0e5b 100644 --- a/University/UniversityClientAppWorker/Views/Home/Index.cshtml +++ b/University/UniversityClientAppWorker/Views/Home/Index.cshtml @@ -45,19 +45,20 @@ @Html.DisplayFor(modelItem => planOfStudy.Id) - - @Html.DisplayFor(modelItem => planOfStudy.Profile) - - - @Html.DisplayFor(modelItem => planOfStudy.FormOfStudy) - - - - + @Html.DisplayFor(modelItem => planOfStudy.Profile) + + + @Html.DisplayFor(modelItem => planOfStudy.FormOfStudy) + + + Изменить +
+ + +
- - } + } diff --git a/University/UniversityClientAppWorker/Views/Home/InfoPlanOfStudy.cshtml b/University/UniversityClientAppWorker/Views/Home/InfoPlanOfStudy.cshtml new file mode 100644 index 0000000..0ef3842 --- /dev/null +++ b/University/UniversityClientAppWorker/Views/Home/InfoPlanOfStudy.cshtml @@ -0,0 +1,30 @@ +@using UniversityContracts.ViewModels +@model PlanOfStudyViewModel +@{ + ViewData["Title"] = "План обучения"; +} +
+

План обучения

+
+
+
+
Профиль:
+
+
+
+
Форма обучения:
+
+
+
+
+
+
+ + + Id + name + academic degree + position + + +
\ No newline at end of file diff --git a/University/UniversityClientAppWorker/Views/Home/PlanOfStudys.cshtml b/University/UniversityClientAppWorker/Views/Home/PlanOfStudys.cshtml deleted file mode 100644 index 4eb2b24..0000000 --- a/University/UniversityClientAppWorker/Views/Home/PlanOfStudys.cshtml +++ /dev/null @@ -1,60 +0,0 @@ -@{ - ViewData["Title"] = "Manage PlansOfStudys"; -} - -
-

@ViewData["Title"]

-
- -
-
-
Profile:
-
- -
-
-
-
FormOfStudy:
-
- -
-
-
-
-
- -
-
-
- - - - - - - - - - - @* @foreach (var discipline in Model) - { - - - - - - - } *@ - -
ProfileFormOfStudyActions
@discipline.Name@discipline.Description - @foreach (var student in discipline.Students) - { - @student.Name - } - - Edit - Details - Delete -
- - diff --git a/University/UniversityClientAppWorker/Views/Home/Students.cshtml b/University/UniversityClientAppWorker/Views/Home/Students.cshtml index 1da391d..62d2843 100644 --- a/University/UniversityClientAppWorker/Views/Home/Students.cshtml +++ b/University/UniversityClientAppWorker/Views/Home/Students.cshtml @@ -1,4 +1,6 @@ -@{ +@using UniversityContracts.ViewModels +@model List +@{ ViewData["Title"] = "Manage Students"; } @@ -36,6 +38,7 @@ + @@ -43,24 +46,30 @@ - @* @foreach (var discipline in Model) + @foreach (var student in Model) { - - + + + - } *@ + }
Id Name Plan of study Phone number
@discipline.Name@discipline.Description - @foreach (var student in discipline.Students) - { - @student.Name - } + @Html.DisplayFor(modelItem => student.Id) - Edit - Details - Delete + @Html.DisplayFor(modelItem => student.Name) + + @Html.DisplayFor(modelItem => student.PlanOfStudyId) + + @Html.DisplayFor(modelItem => student.PhoneNumber) + + Изменить +
+ + +
diff --git a/University/UniversityDatabaseImplement/Implements/PlanOfStudyStorage.cs b/University/UniversityDatabaseImplement/Implements/PlanOfStudyStorage.cs index 7a5d86b..1b9f47c 100644 --- a/University/UniversityDatabaseImplement/Implements/PlanOfStudyStorage.cs +++ b/University/UniversityDatabaseImplement/Implements/PlanOfStudyStorage.cs @@ -53,16 +53,24 @@ namespace UniversityDatabaseImplement.Implements public List GetFilteredList(PlanOfStudySearchModel model) { + if(model == null) + { + return new(); + } using var context = new UniversityDatabase(); var query = context.PlanOfStudys .Include(x => x.Students) - .Where(x => x.Id == model.Id) + .Include(x => x.User) .AsQueryable(); + if (model.Id.HasValue) + { + query = query.Where(x => x.Id == model.Id.Value); + } if (model.DateFrom.HasValue && model.DateTo.HasValue) { query = query.Where(x => model.DateFrom.Value <= x.Date && x.Date <= model.DateTo.Value); - } - return new(); + }; + return query.Select(x => x.GetViewModel).ToList(); } public PlanOfStudyViewModel? GetElement(PlanOfStudySearchModel model) diff --git a/University/UniversityDatabaseImplement/UniversityDatabase.cs b/University/UniversityDatabaseImplement/UniversityDatabase.cs index 07213d0..2b73bad 100644 --- a/University/UniversityDatabaseImplement/UniversityDatabase.cs +++ b/University/UniversityDatabaseImplement/UniversityDatabase.cs @@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement if (optionsBuilder.IsConfigured == false) { //Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR - optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-N8BRIPR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DyCTaTOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/University/UniversityRestApi/Controllers/PlanOfStudysController.cs b/University/UniversityRestApi/Controllers/PlanOfStudysController.cs index fcb81ab..5d2c119 100644 --- a/University/UniversityRestApi/Controllers/PlanOfStudysController.cs +++ b/University/UniversityRestApi/Controllers/PlanOfStudysController.cs @@ -43,7 +43,7 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpPut] + [HttpPost] public void UpdatePlanOfStudy(PlanOfStudyBindingModel model) { try @@ -56,7 +56,7 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpDelete] + [HttpPost] public void DeletePlanOfStudy(PlanOfStudyBindingModel model) { try