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