From d3acce8dd5b08ca2ae85ce12ef0d6259568c9e71 Mon Sep 17 00:00:00 2001 From: GokaPek Date: Thu, 30 May 2024 04:16:38 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B5=D0=B4=D0=BE=D0=BC=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8=20=D0=BA=D1=80=D1=83=D0=B4=20=D0=B2=D1=80=D0=BE?= =?UTF-8?q?=D0=B4=D0=B5=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 55 ++++++++++++++++++- .../Views/Home/InfoStatement.cshtml | 41 ++++++++++++++ .../Views/Home/Statements.cshtml | 10 ++++ .../Models/Statement.cs | 3 +- .../Controllers/StatementController.cs | 18 +++++- 5 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 University/UniversityClientApp/Views/Home/InfoStatement.cshtml diff --git a/University/UniversityClientApp/Controllers/HomeController.cs b/University/UniversityClientApp/Controllers/HomeController.cs index c0c6720..5c6372e 100644 --- a/University/UniversityClientApp/Controllers/HomeController.cs +++ b/University/UniversityClientApp/Controllers/HomeController.cs @@ -314,7 +314,7 @@ namespace UniversityClientApp.Controllers } if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(academicdegree) || string.IsNullOrEmpty(position)) { - throw new Exception(" "); + throw new Exception(""); } APIStorekeeper.PostRequest("api/teacher/updateteacher", new TeacherBindingModel @@ -328,6 +328,59 @@ namespace UniversityClientApp.Controllers } + // + + [HttpPost] + public void DeleteStatement(int id) + { + if (id == 0) + { + throw new Exception("id 0"); + } + APIStorekeeper.PostRequest("api/statement/deletestatement", new StatementBindingModel + { + Id = id + }); + Response.Redirect("Statements"); + } + + [HttpGet] + public IActionResult InfoStatement(int id) + { + if (APIStorekeeper.Client == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Teachers = APIStorekeeper.GetRequest>($"api/teacher/getteachers?userId={APIStorekeeper.Client.Id}"); + var obj = APIStorekeeper.GetRequest($"api/statement/getstatement?userId={APIStorekeeper.Client.Id}&id={id}"); + return View(obj); + } + + [HttpPost] + public void UpdateStatement(int id, string name, DateTime date, int teacher) + { + if (APIStorekeeper.Client == null) + { + throw new Exception(" "); + } + if (string.IsNullOrEmpty(name) || teacher == 0) + { + throw new Exception(""); + } + + APIStorekeeper.PostRequest("api/statement/updatestatement", new StatementBindingModel + { + Id = id, + Name = name, + Date = date, + TeacherId = teacher + }); + Response.Redirect("Statements"); + } + + + // + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/University/UniversityClientApp/Views/Home/InfoStatement.cshtml b/University/UniversityClientApp/Views/Home/InfoStatement.cshtml new file mode 100644 index 0000000..6ebf518 --- /dev/null +++ b/University/UniversityClientApp/Views/Home/InfoStatement.cshtml @@ -0,0 +1,41 @@ +@using UniversityContracts.ViewModels +@model StatementViewModel +@{ + ViewData["Title"] = "Ведомость"; +} + +
+

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

+
+ + +
+
+
Название:
+
+ +
+
+
+
Дата:
+
+ +
+
+
+
Преподаватель:
+
+ +
+
+
+
+
+ + + + + +
+
+ \ No newline at end of file diff --git a/University/UniversityClientApp/Views/Home/Statements.cshtml b/University/UniversityClientApp/Views/Home/Statements.cshtml index cf81577..7c272c7 100644 --- a/University/UniversityClientApp/Views/Home/Statements.cshtml +++ b/University/UniversityClientApp/Views/Home/Statements.cshtml @@ -44,6 +44,7 @@ Название Дата Преподаватель + Действие @foreach (var item in Model) @@ -61,6 +62,15 @@ @Html.DisplayFor(modelItem => item.TeacherName) + +
+ Изменить +
+ + +
+
+ } diff --git a/University/UniversityDatabaseImplement/Models/Statement.cs b/University/UniversityDatabaseImplement/Models/Statement.cs index ee5ddca..46e55ca 100644 --- a/University/UniversityDatabaseImplement/Models/Statement.cs +++ b/University/UniversityDatabaseImplement/Models/Statement.cs @@ -58,8 +58,7 @@ namespace UniversityDatabaseImplement.Models return; } Id = model.Id; - UserId = model.UserId; - TeacherId = model.Id; + //TeacherId = model.Id; Name = model.Name; Date = model.Date; } diff --git a/University/UniversityRestApi/Controllers/StatementController.cs b/University/UniversityRestApi/Controllers/StatementController.cs index 04e8857..490ed6f 100644 --- a/University/UniversityRestApi/Controllers/StatementController.cs +++ b/University/UniversityRestApi/Controllers/StatementController.cs @@ -38,6 +38,20 @@ namespace UniversityRestApi.Controllers } } + [HttpGet] + public StatementViewModel? GetStatement(int userId, int id) + { + try + { + return _logic.ReadElement(new StatementSearchModel { UserId = userId, Id = id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения ведомости id={Id}", userId); + throw; + } + } + [HttpPost] public void CreateStatement(StatementBindingModel model) { @@ -50,7 +64,7 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpPut] + [HttpPost] public void UpdateStatement(StatementBindingModel model) { try @@ -63,7 +77,7 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpDelete] + [HttpPost] public void DeleteStatement(StatementBindingModel model) { try