diff --git a/University/UniversityClientApp/Controllers/HomeController.cs b/University/UniversityClientApp/Controllers/HomeController.cs index 535eb19..42dd952 100644 --- a/University/UniversityClientApp/Controllers/HomeController.cs +++ b/University/UniversityClientApp/Controllers/HomeController.cs @@ -381,6 +381,55 @@ namespace UniversityClientApp.Controllers // Δθρφθολθνΰ + [HttpGet] + public async Task InfoDiscipline(int id) + { + if (APIStorekeeper.Client == null) + { + return Redirect("~/Home/Enter"); + } + var obj1 = APIStorekeeper.GetRequest>($"api/student/getallstudents"); + ViewBag.Students = obj1; + var obj2 = APIStorekeeper.GetRequest>($"api/teacher/getteachers?userId={APIStorekeeper.Client.Id}"); + ViewBag.Teachers = obj2; + var obj = await APIStorekeeper.GetRequestDisciplineAsync($"api/discipline/getdiscipline?id={id}&userId={APIStorekeeper.Client.Id}"); + return View(obj); + } + + [HttpPost] + public void DeleteDiscipline(int id) + { + if (id == 0) + { + throw new Exception("id νε μξζες αϋςό πΰβεν 0"); + } + APIStorekeeper.PostRequest("api/discipline/deletediscipline", new DisciplineBindingModel + { + Id = id + }); + Response.Redirect("Disciplines"); + } + [HttpPost] + public void UpdateDiscipline(int id, string name, string description, int teacher, List studentIds, DateOnly date) + { + if (id == 0) + { + throw new Exception("id νε μξζες αϋςό πΰβεν 0"); + } + var disciplineStudents = studentIds.ToDictionary(id => id, id => (IStudentModel)null); + APIStorekeeper.PostRequest("api/discipline/updatediscipline", new DisciplineBindingModel + { + Id = id, + Name = name, + Description = description, + TeacherId = teacher, + StudentDisciplines = disciplineStudents, + Date = date + }); + Response.Redirect("Disciplines"); + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/University/UniversityClientApp/Views/Home/Disciplines.cshtml b/University/UniversityClientApp/Views/Home/Disciplines.cshtml index 9b8fff1..8107b68 100644 --- a/University/UniversityClientApp/Views/Home/Disciplines.cshtml +++ b/University/UniversityClientApp/Views/Home/Disciplines.cshtml @@ -73,7 +73,7 @@ ОписаниС Π”Π°Ρ‚Π° Имя учитСля - ДСйствиС + @@ -91,6 +91,15 @@ @Html.DisplayFor(modelItem => item.TeacherName) + +
+ Π˜Π·ΠΌΠ΅Π½ΠΈΡ‚ΡŒ +
+ + +
+
+ } diff --git a/University/UniversityClientApp/Views/Home/InfoDiscipline.cshtml b/University/UniversityClientApp/Views/Home/InfoDiscipline.cshtml new file mode 100644 index 0000000..b61c086 --- /dev/null +++ b/University/UniversityClientApp/Views/Home/InfoDiscipline.cshtml @@ -0,0 +1,64 @@ +ο»Ώ@using UniversityContracts.ViewModels +@model DisciplineViewModel +@{ + ViewData["Title"] = "Дисциплина"; +} +
+

@ViewData["Title"] - @Model.Id

+
+
+
+
НазваниС:
+
+ +
+
+
+
ОписаниС:
+
+ +
+
+ +
+
Π”Π°Ρ‚Π°:
+
+ +
+
+
+
ΠŸΡ€Π΅ΠΏΠΎΠ΄Π°Π²Π°Ρ‚Π΅Π»ΡŒ:
+
+ +
+
+ + +
+
Π‘Ρ‚ΡƒΠ΄Π΅Π½Ρ‚Ρ‹:
+
+
+ @foreach (var student in ViewBag.Students) + { +
+ + +
+ } +
+
+
+
+
+
+ + + + + +
+
+ diff --git a/University/UniversityClientApp/Views/Home/InfoTeacher.cshtml b/University/UniversityClientApp/Views/Home/InfoTeacher.cshtml index a2b184a..cb4a092 100644 --- a/University/UniversityClientApp/Views/Home/InfoTeacher.cshtml +++ b/University/UniversityClientApp/Views/Home/InfoTeacher.cshtml @@ -25,12 +25,6 @@ -
-
-
- -
-
diff --git a/University/UniversityDatabaseImplement/Models/Discipline.cs b/University/UniversityDatabaseImplement/Models/Discipline.cs index 3b540d4..8194ffe 100644 --- a/University/UniversityDatabaseImplement/Models/Discipline.cs +++ b/University/UniversityDatabaseImplement/Models/Discipline.cs @@ -67,7 +67,6 @@ namespace UniversityDatabaseImplement.Models return; } Id = model.Id; - UserId = model.UserId; TeacherId = model.TeacherId; Name = model.Name; Description = model.Description; diff --git a/University/UniversityDatabaseImplement/UniversityDatabase.cs b/University/UniversityDatabaseImplement/UniversityDatabase.cs index 3eebb86..07213d0 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=LAPTOP-DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-N8BRIPR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/University/UniversityRestApi/Controllers/DisciplineController .cs b/University/UniversityRestApi/Controllers/DisciplineController .cs index 0ad705c..de3c40d 100644 --- a/University/UniversityRestApi/Controllers/DisciplineController .cs +++ b/University/UniversityRestApi/Controllers/DisciplineController .cs @@ -23,20 +23,22 @@ namespace UniversityRestApi.Controllers _reportLogic = reportLogic; _mailWorker = mailWorker; } - /*[HttpGet] - public List? GetDisciplines(int userId) + + [HttpGet] + public DisciplineViewModel? GetDiscipline(int id, int userId) { try { - return _logic.ReadList(new DisciplineSearchModel { UserId = userId }); + return _logic.ReadElement(new DisciplineSearchModel { Id = id, UserId = userId }); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получСния списка дисциплин"); + _logger.LogError(ex, "Ошибка получСния списка ΠΏΠ»Π°Π½ΠΎΠ² обучСния"); throw; } - }*/ - [HttpGet] + } + + [HttpGet] public List? GetDisciplines() { try @@ -89,7 +91,7 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpPut] + [HttpPost] public void UpdateDiscipline(DisciplineBindingModel model) { try @@ -102,7 +104,7 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpDelete] + [HttpPost] public void DeleteDiscipline(DisciplineBindingModel model) { try diff --git a/University/UniversityRestApi/Controllers/StudentController.cs b/University/UniversityRestApi/Controllers/StudentController.cs index 1786a4e..3f53467 100644 --- a/University/UniversityRestApi/Controllers/StudentController.cs +++ b/University/UniversityRestApi/Controllers/StudentController.cs @@ -31,6 +31,19 @@ namespace UniversityRestApi.Controllers } } [HttpGet] + public List? GetAllStudents() + { + try + { + return _logic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка "); + throw; + } + } + [HttpGet] public StudentViewModel? GetStudent(int userId, int studentId) { try