From 85159ea8afc3f3a5aa3d0b7bfb6f38ff35f92cce Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Wed, 29 May 2024 21:59:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=BC=D0=B5=D0=B6=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 20 ++++++++++ .../Views/Home/Attestations.cshtml | 2 +- .../Views/Home/InfoAttestation.cshtml | 38 +++++++++++++++++++ .../IAttestationLogic.cs | 1 + .../Models/IAttestationModel.cs | 1 - .../UniversityDatabase.cs | 2 +- .../Controllers/AttestationController.cs | 17 ++++++++- .../Controllers/StudentController.cs | 13 +++++++ 8 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 University/UniversityClientAppWorker/Views/Home/InfoAttestation.cshtml diff --git a/University/UniversityClientAppWorker/Controllers/HomeController.cs b/University/UniversityClientAppWorker/Controllers/HomeController.cs index 7962177..5809915 100644 --- a/University/UniversityClientAppWorker/Controllers/HomeController.cs +++ b/University/UniversityClientAppWorker/Controllers/HomeController.cs @@ -1,3 +1,4 @@ +using DocumentFormat.OpenXml.Office2010.Excel; using Microsoft.AspNetCore.Mvc; using PlumbingRepairClientApp; using System.Diagnostics; @@ -149,15 +150,34 @@ namespace UniversityClientAppWorker.Controllers { 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/createattestation", new AttestationBindingModel { UserId = APIClient.User.Id, FormOfEvaluation = formOfEvaluation, StudentId = student, + StudentName = Student.Name, Score = score }); Response.Redirect("Attestations"); } + [HttpGet] + public async Task InfoAttestation(int id) + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + 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}"); + return View(obj); + } [HttpGet] public async Task Students() { diff --git a/University/UniversityClientAppWorker/Views/Home/Attestations.cshtml b/University/UniversityClientAppWorker/Views/Home/Attestations.cshtml index fb2d3c5..3320ecf 100644 --- a/University/UniversityClientAppWorker/Views/Home/Attestations.cshtml +++ b/University/UniversityClientAppWorker/Views/Home/Attestations.cshtml @@ -67,7 +67,7 @@
- Изменить + Изменить
diff --git a/University/UniversityClientAppWorker/Views/Home/InfoAttestation.cshtml b/University/UniversityClientAppWorker/Views/Home/InfoAttestation.cshtml new file mode 100644 index 0000000..a1c5ae0 --- /dev/null +++ b/University/UniversityClientAppWorker/Views/Home/InfoAttestation.cshtml @@ -0,0 +1,38 @@ +@using UniversityContracts.ViewModels +@model AttestationViewModel +@{ + ViewData["Title"] = "Аттестация"; +} +
+

Аттестация

+
+ +
+
Форма оценивания:
+
+ +
+
+
+
Студент:
+
+ +
+
+
+
Оценка:
+
+ +
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/University/UniversityContracts/BusinessLogicsContracts/IAttestationLogic.cs b/University/UniversityContracts/BusinessLogicsContracts/IAttestationLogic.cs index 7df94d5..d990a57 100644 --- a/University/UniversityContracts/BusinessLogicsContracts/IAttestationLogic.cs +++ b/University/UniversityContracts/BusinessLogicsContracts/IAttestationLogic.cs @@ -12,6 +12,7 @@ namespace UniversityContracts.BusinessLogicsContracts public interface IAttestationLogic { List? ReadList(AttestationSearchModel? model); + AttestationViewModel? ReadElement(AttestationSearchModel model); bool CreateAttestation(AttestationBindingModel model); bool DeleteAttestation(AttestationBindingModel model); bool UpdateAttestation(AttestationBindingModel model); diff --git a/University/UniversityDataModels/Models/IAttestationModel.cs b/University/UniversityDataModels/Models/IAttestationModel.cs index 084cdfb..9c2ea2e 100644 --- a/University/UniversityDataModels/Models/IAttestationModel.cs +++ b/University/UniversityDataModels/Models/IAttestationModel.cs @@ -5,7 +5,6 @@ namespace UniversityDataModels.Models public interface IAttestationModel : IId { int UserId { get; } - string StudentName { get; } string FormOfEvaluation { get; } AttestationScore Score { get; } int StudentId { get; } diff --git a/University/UniversityDatabaseImplement/UniversityDatabase.cs b/University/UniversityDatabaseImplement/UniversityDatabase.cs index 3eebb86..85c48bf 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=DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/University/UniversityRestApi/Controllers/AttestationController.cs b/University/UniversityRestApi/Controllers/AttestationController.cs index a7cae0d..5f8f581 100644 --- a/University/UniversityRestApi/Controllers/AttestationController.cs +++ b/University/UniversityRestApi/Controllers/AttestationController.cs @@ -32,6 +32,19 @@ namespace UniversityRestApi.Controllers throw; } } + [HttpGet] + public AttestationViewModel? GetAttestation(int userId, int id) + { + try + { + return _logic.ReadElement(new AttestationSearchModel { UserId = userId, Id = id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения аттестаций пользователя id={Id}", userId); + throw; + } + } [HttpPost] public void CreateAttestation(AttestationBindingModel model) { @@ -44,7 +57,7 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpPut] + [HttpPost] public void UpdateAttestation(AttestationBindingModel model) { try @@ -57,7 +70,7 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpDelete] + [HttpPost] public void DeleteAttestation(AttestationBindingModel model) { try diff --git a/University/UniversityRestApi/Controllers/StudentController.cs b/University/UniversityRestApi/Controllers/StudentController.cs index 06734a7..24c3e49 100644 --- a/University/UniversityRestApi/Controllers/StudentController.cs +++ b/University/UniversityRestApi/Controllers/StudentController.cs @@ -30,6 +30,19 @@ namespace UniversityRestApi.Controllers throw; } } + [HttpGet] + public StudentViewModel? GetStudent(int userId, int studentId) + { + try + { + return _logic.ReadElement(new StudentSearchModel { UserId = userId, Id = studentId }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка студентов пользователя id={Id}", userId); + throw; + } + } [HttpPost] public void CreateStudent(StudentBindingModel model) {