From b4e85ced887d0b68fd4318a749f3096875ff89bd Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Mon, 27 May 2024 22:35:38 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D1=81=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 25 ++++++++++++- .../Views/Home/Index.cshtml | 14 ++++---- .../Views/Home/Students.cshtml | 36 ++++++++++--------- .../Implements/StudentStorage.cs | 5 ++- .../Models/Attestation.cs | 1 - .../Controllers/UserController.cs | 10 +++++- 6 files changed, 62 insertions(+), 29 deletions(-) diff --git a/University/UniversityClientAppWorker/Controllers/HomeController.cs b/University/UniversityClientAppWorker/Controllers/HomeController.cs index efdbbe8..fbacfda 100644 --- a/University/UniversityClientAppWorker/Controllers/HomeController.cs +++ b/University/UniversityClientAppWorker/Controllers/HomeController.cs @@ -120,9 +120,32 @@ namespace UniversityClientAppWorker.Controllers { return Redirect("~/Home/Enter"); } + ViewBag.PlanOfStudys = APIClient.GetRequest> + ($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}"); return View(APIClient.GetRequest>($"api/student/getstudents?userId={APIClient.User.Id}")); } - [HttpGet] + [HttpPost] + public void CreateStudent(string name, int planOfStudy, string phoneNumber) + { + if (APIClient.User == null) + { + throw new Exception(" "); + } + if (string.IsNullOrEmpty(name) || planOfStudy == 0 || string.IsNullOrEmpty(phoneNumber)) + { + throw new Exception(" , "); + } + APIClient.PostRequest("api/student/createstudent", new StudentBindingModel + { + UserId = APIClient.User.Id, + Name = name, + PlanOfStudyId = planOfStudy, + PhoneNumber = phoneNumber, + + }); + Response.Redirect("Students"); + } + [HttpGet] public IActionResult Enter() { return View(); diff --git a/University/UniversityClientAppWorker/Views/Home/Index.cshtml b/University/UniversityClientAppWorker/Views/Home/Index.cshtml index dbd0e5b..32e222b 100644 --- a/University/UniversityClientAppWorker/Views/Home/Index.cshtml +++ b/University/UniversityClientAppWorker/Views/Home/Index.cshtml @@ -24,7 +24,7 @@
- +
@@ -52,11 +52,13 @@ @Html.DisplayFor(modelItem => planOfStudy.FormOfStudy) - Изменить -
- - -
+
+ Изменить +
+ + +
+
} diff --git a/University/UniversityClientAppWorker/Views/Home/Students.cshtml b/University/UniversityClientAppWorker/Views/Home/Students.cshtml index 62d2843..ec45aac 100644 --- a/University/UniversityClientAppWorker/Views/Home/Students.cshtml +++ b/University/UniversityClientAppWorker/Views/Home/Students.cshtml @@ -1,36 +1,36 @@ @using UniversityContracts.ViewModels @model List @{ - ViewData["Title"] = "Manage Students"; + ViewData["Title"] = "Управление студентами"; }

@ViewData["Title"]

-
+
-
Name:
+
ФИО:
-
Plan Of Study:
+
План обучения:
- +
-
Phone number:
+
Номер телефона:
-
- +
+
@@ -39,10 +39,10 @@ Id - Name - Plan of study - Phone number - Actions + ФИО + План обучения + Номер телефона + Действия @@ -62,11 +62,13 @@ @Html.DisplayFor(modelItem => student.PhoneNumber) - Изменить -
- - -
+
+ Изменить +
+ + +
+
} diff --git a/University/UniversityDatabaseImplement/Implements/StudentStorage.cs b/University/UniversityDatabaseImplement/Implements/StudentStorage.cs index 8ecad2e..d95f42b 100644 --- a/University/UniversityDatabaseImplement/Implements/StudentStorage.cs +++ b/University/UniversityDatabaseImplement/Implements/StudentStorage.cs @@ -25,7 +25,7 @@ namespace UniversityDatabaseImplement.Implements public List GetFilteredList(StudentSearchModel model) { - if (string.IsNullOrEmpty(model.Name)) + if (model == null) { return new(); } @@ -34,8 +34,7 @@ namespace UniversityDatabaseImplement.Implements return context.Students .Include(x => x.User) - .Where(x => x.Name - .Contains(model.Name)) + .Include(x => x.PlanOfStudy) .Select(x => x.GetViewModel) .ToList(); } diff --git a/University/UniversityDatabaseImplement/Models/Attestation.cs b/University/UniversityDatabaseImplement/Models/Attestation.cs index be6fb63..36c3a46 100644 --- a/University/UniversityDatabaseImplement/Models/Attestation.cs +++ b/University/UniversityDatabaseImplement/Models/Attestation.cs @@ -8,7 +8,6 @@ using UniversityContracts.BindingModels; using UniversityContracts.ViewModels; using UniversityDataModels.Enums; using UniversityDataModels.Models; -using static System.Formats.Asn1.AsnWriter; namespace UniversityDatabaseImplement.Models { diff --git a/University/UniversityRestApi/Controllers/UserController.cs b/University/UniversityRestApi/Controllers/UserController.cs index 5374327..4538166 100644 --- a/University/UniversityRestApi/Controllers/UserController.cs +++ b/University/UniversityRestApi/Controllers/UserController.cs @@ -20,7 +20,6 @@ namespace UniversityRestApi.Controllers _logger = logger; } - [HttpGet] public UserViewModel? LoginWorker(string login, string password) { @@ -124,5 +123,14 @@ namespace UniversityRestApi.Controllers throw; } } + [HttpGet] + public List GetAll(UserSearchModel? model) + { + try + { + return _logic.ReadList(model); + } + catch (Exception ex) { throw new Exception(); } + } } }