From d6e5e9dced9d7f73cc5802e53ea67b08b39f3fb1 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Wed, 29 May 2024 22:48:30 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=90=D1=82=D1=82=D0=B5=D1=81=D1=82=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 44 ++++++++++++++++++- .../Views/Home/InfoAttestation.cshtml | 7 +-- .../Views/Home/InfoPlanOfStudy.cshtml | 2 +- .../UniversityDatabase.cs | 2 +- 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/University/UniversityClientAppWorker/Controllers/HomeController.cs b/University/UniversityClientAppWorker/Controllers/HomeController.cs index 5809915..f53d064 100644 --- a/University/UniversityClientAppWorker/Controllers/HomeController.cs +++ b/University/UniversityClientAppWorker/Controllers/HomeController.cs @@ -167,7 +167,7 @@ namespace UniversityClientAppWorker.Controllers Response.Redirect("Attestations"); } [HttpGet] - public async Task InfoAttestation(int id) + public IActionResult InfoAttestation(int id) { if (APIClient.User == null) { @@ -175,9 +175,49 @@ namespace UniversityClientAppWorker.Controllers } ViewBag.Students = APIClient.GetRequest>($"api/student/getstudents?userId={APIClient.User.Id}"); ViewBag.AttestationScore = Enum.GetValues(typeof(AttestationScore)).Cast(); - var obj = await APIClient.GetRequestAsync($"api/attestation/getattestation?userId={APIClient.User.Id}&id={id}"); + var obj = APIClient.GetRequest($"api/attestation/getattestation?userId={APIClient.User.Id}&id={id}"); return View(obj); } + [HttpPost] + public void UpdateAttestation(int id, string formOfEvaluation, int student, AttestationScore score) + { + if (APIClient.User == null) + { + throw new Exception(" "); + } + if (string.IsNullOrEmpty(formOfEvaluation) || student == 0) + { + throw new Exception(" "); + } + var Student = APIClient.GetRequest($"api/student/getstudent?userId={APIClient.User.Id}&studentId={student}"); + + if (Student == null) + { + throw new Exception(" "); + } + APIClient.PostRequest("api/attestation/updateattestation", new AttestationBindingModel + { + Id = id, + FormOfEvaluation = formOfEvaluation, + StudentId = student, + StudentName = Student.Name, + Score = score + }); + Response.Redirect("Attestations"); + } + [HttpPost] + public void DeleteAttestation(int id) + { + if (id == 0) + { + throw new Exception("id 0"); + } + APIClient.PostRequest("api/attestation/deleteattestation", new PlanOfStudyBindingModel + { + Id = id + }); + Response.Redirect("Attestations"); + } [HttpGet] public async Task Students() { diff --git a/University/UniversityClientAppWorker/Views/Home/InfoAttestation.cshtml b/University/UniversityClientAppWorker/Views/Home/InfoAttestation.cshtml index a1c5ae0..43ada8d 100644 --- a/University/UniversityClientAppWorker/Views/Home/InfoAttestation.cshtml +++ b/University/UniversityClientAppWorker/Views/Home/InfoAttestation.cshtml @@ -1,10 +1,10 @@ @using UniversityContracts.ViewModels @model AttestationViewModel @{ - ViewData["Title"] = "Аттестация"; + ViewData["Title"] = "План обучения"; }
-

Аттестация

+

@ViewData["Title"]

@@ -26,12 +26,13 @@
Оценка:
- +
+
diff --git a/University/UniversityClientAppWorker/Views/Home/InfoPlanOfStudy.cshtml b/University/UniversityClientAppWorker/Views/Home/InfoPlanOfStudy.cshtml index 68c4eda..8eadf37 100644 --- a/University/UniversityClientAppWorker/Views/Home/InfoPlanOfStudy.cshtml +++ b/University/UniversityClientAppWorker/Views/Home/InfoPlanOfStudy.cshtml @@ -4,7 +4,7 @@ ViewData["Title"] = "План обучения"; }
-

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

+

@ViewData["Title"]

diff --git a/University/UniversityDatabaseImplement/UniversityDatabase.cs b/University/UniversityDatabaseImplement/UniversityDatabase.cs index 85c48bf..3eebb86 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=DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); }