Круды препода финал
This commit is contained in:
parent
acbac6aadb
commit
ad24e2c38c
@ -27,7 +27,6 @@ namespace UniversityClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
//return View(APIStorekeeper.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}"));
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -154,7 +153,6 @@ namespace UniversityClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
//ViewBag.Documents = APIStorekeeper.GetRequest<List<DisciplineViewModel>>("api/main/getdiscipline");
|
||||
return View(APIStorekeeper.GetRequest<List<TeacherViewModel>>($"api/teacher/getteachers?userId={APIStorekeeper.Client.Id}"));
|
||||
}
|
||||
[HttpPost]
|
||||
@ -252,10 +250,6 @@ namespace UniversityClientApp.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
|
||||
// Ïîëó÷àåì äàííûå îò ñåðâåðà
|
||||
//var reportData = APIStorekeeper.GetRequest<List<ReportDisciplineViewModel>>($"api/disciplines/GetReportDisciplines?datefrom={dateFrom}&dateto={dateTo}");
|
||||
|
||||
// Ïåðåäàåì äàííûå â ÷àñòè÷íîå ïðåäñòàâëåíèå
|
||||
if (dateFrom == DateOnly.MinValue || dateTo == DateOnly.MaxValue)
|
||||
{
|
||||
@ -281,6 +275,59 @@ namespace UniversityClientApp.Controllers
|
||||
}
|
||||
|
||||
|
||||
// UDS
|
||||
|
||||
|
||||
// Ïðåïîäàâàòåëü
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteTeacher(int id)
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
throw new Exception("id íå ìîæåò áûòü ðàâåí 0");
|
||||
}
|
||||
APIStorekeeper.PostRequest("api/teacher/deleteteacher", new TeacherBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
Response.Redirect("Teachers");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult InfoTeacher(int id)
|
||||
{
|
||||
if (APIStorekeeper.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
var obj = APIStorekeeper.GetRequest<TeacherViewModel>($"api/teacher/getteacher?userId={APIStorekeeper.Client.Id}&id={id}");
|
||||
return View(obj);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateTeacher(int id, string name, string academicdegree, string position)
|
||||
{
|
||||
if (APIStorekeeper.Client == null)
|
||||
{
|
||||
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(academicdegree) || string.IsNullOrEmpty(position))
|
||||
{
|
||||
throw new Exception("Ââåäèòå ôîðìó îöåíèâàíèÿ è âûáåðèòå ñòóäåíòà");
|
||||
}
|
||||
|
||||
APIStorekeeper.PostRequest("api/teacher/updateteacher", new TeacherBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
AcademicDegree = academicdegree,
|
||||
Position = position
|
||||
});
|
||||
Response.Redirect("Teachers");
|
||||
}
|
||||
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
|
44
University/UniversityClientApp/Views/Home/InfoTeacher.cshtml
Normal file
44
University/UniversityClientApp/Views/Home/InfoTeacher.cshtml
Normal file
@ -0,0 +1,44 @@
|
||||
@using UniversityContracts.ViewModels
|
||||
@model TeacherViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Преподаватель";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@ViewData["Title"] - @Model.Id</h2>
|
||||
</div>
|
||||
<form asp-action="UpdateTeacher" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Имя:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" id="name" class="form-control" value="@Model.Name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Учёная степень:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="academicDegree" id="academicDegree" class="form-control" value="@Model.AcademicDegree" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Должность:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="position" id="position" class="form-control" value="@Model.Position" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Create Teacher" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4 mt-2">
|
||||
<form asp-action="Teachers">
|
||||
<input type="submit" value="Отмена" class="btn btn-primary" />
|
||||
</form>
|
||||
<input type="hidden" name="id" value="@Model.Id" />
|
||||
<input type="submit" value="Сохранить" class="btn btn-danger" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -43,6 +43,7 @@
|
||||
<th>Имя</th>
|
||||
<th>Учёная степень</th>
|
||||
<th>Должность</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -61,6 +62,15 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Position)
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a asp-controller="Home" asp-action="InfoTeacher" asp-route-id="@item.Id" class="btn btn-warning">Изменить</a>
|
||||
<form asp-controller="Home" asp-action="DeleteTeacher" method="post">
|
||||
<input type="hidden" name="id" value="@item.Id" />
|
||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
@ -64,7 +64,6 @@ namespace UniversityDatabaseImplement.Models
|
||||
return;
|
||||
}
|
||||
Id = model.Id;
|
||||
UserId = model.UserId;
|
||||
Name = model.Name;
|
||||
AcademicDegree = model.AcademicDegree;
|
||||
Position = model.Position;
|
||||
|
@ -20,6 +20,21 @@ namespace UniversityRestApi.Controllers
|
||||
_logger = logger;
|
||||
_reportLogic = reportLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public TeacherViewModel? GetTeacher(int userId, int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new TeacherSearchModel { UserId = userId, Id = id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения teacher user {Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<TeacherViewModel>? GetTeachers(int userId)
|
||||
{
|
||||
@ -59,7 +74,7 @@ namespace UniversityRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
[HttpPost]
|
||||
public void UpdateTeacher(TeacherBindingModel model)
|
||||
{
|
||||
try
|
||||
@ -72,7 +87,7 @@ namespace UniversityRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
[HttpPost]
|
||||
public void DeleteTeacher(TeacherBindingModel model)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user