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