Дисциплины

This commit is contained in:
GokaPek 2024-05-27 23:53:45 +04:00
parent 669f02e5aa
commit 0d7809310a
6 changed files with 54 additions and 31 deletions

View File

@ -75,9 +75,32 @@ namespace UniversityClientApp.Controllers
return;
}
public IActionResult Disciplines()
[HttpGet]
public IActionResult Disciplines()
{
return View();
if (APIStorekeeper.Client == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Teachers = APIStorekeeper.GetRequest<List<TeacherViewModel>>($"api/teacher/getteachers?userId={APIStorekeeper.Client.Id}");
return View(APIStorekeeper.GetRequest<List<DisciplineViewModel>>($"api/discipline/getdisciplines?teacherId={0}"));
}
[HttpPost]
public void Disciplines(string name, string description, DateOnly date, int teacher)
{
if (APIStorekeeper.Client == null)
{
Redirect("~/Home/Enter");
}
APIStorekeeper.PostRequest("api/discipline/creatediscipline", new DisciplineBindingModel
{
UserId = APIStorekeeper.Client.Id,
Name = name,
Description = description,
Date = date,
TeacherId = teacher,
});
Response.Redirect("Disciplines");
}
[HttpGet]

View File

@ -1,4 +1,6 @@
@{
@using UniversityContracts.ViewModels
@model List<DisciplineViewModel>
@{
ViewData["Title"] = "Manage Disciplines";
}
@ -20,12 +22,20 @@
<textarea name="description" id="description" class="form-control"></textarea>
</div>
</div>
<div class="row">
<div class="col-4">Students:</div>
<div class="col-4">Date:</div>
<div class="col-8">
<select id="students" name="students" class="form-control" multiple asp-items="ViewBag.Students"></select>
<input type="date" name="date" id="date" class="form-control" />
</div>
</div>
<div class="row">
<div class="col-4">Teacher:</div>
<div class="col-8">
<select id="teacher" name="teacher" class="form-control" asp-items="@(new SelectList(@ViewBag.Teachers,"Id", "Name"))"></select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
@ -39,29 +49,29 @@
<tr>
<th>Name</th>
<th>Description</th>
<th>Students</th>
<th>Date</th>
<th>Teacher Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@* @foreach (var discipline in Model)
@foreach (var item in Model)
{
<tr>
<td>@discipline.Name</td>
<td>@discipline.Description</td>
<td>
@foreach (var student in discipline.Students)
{
<span>@student.Name</span>
}
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
<a asp-action="Edit" asp-route-id="@discipline.Id" class="btn btn-warning">Edit</a>
<a asp-action="Details" asp-route-id="@discipline.Id" class="btn btn-info">Details</a>
<a asp-action="Delete" asp-route-id="@discipline.Id" class="btn btn-danger">Delete</a>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Date)
</td>
<td>
@Html.DisplayFor(modelItem => item.TeacherName)
</td>
</tr>
} *@
}
</tbody>
</table>

View File

@ -28,12 +28,6 @@
<input type="text" name="position" id="position" class="form-control" />
</div>
</div>
<div class="row">
<div class="col-4">Disciplines:</div>
<div class="col-8">
<select id="disciplines" name="disciplines" class="form-control" multiple asp-items="ViewBag.Disciplines"></select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
@ -49,7 +43,6 @@
<th>Name</th>
<th>Academic Degree</th>
<th>Position</th>
<th>Disciplines</th>
</tr>
</thead>
<tbody>
@ -67,11 +60,6 @@
</td>
<td>
@Html.DisplayFor(modelItem => item.Position)
</td>
<td>
</td>
</tr>
}

View File

@ -13,6 +13,7 @@ namespace UniversityContracts.ViewModels
public int Id { get; set; }
public int UserId { get; set; }
public int TeacherId { get; set; }
public string TeacherName { get; set; } = string.Empty;
[DisplayName("Название дисциплины")]
public string Name { get; set; } = string.Empty;
[DisplayName("Описание дисциплины")]

View File

@ -105,6 +105,7 @@ namespace UniversityDatabaseImplement.Models
Id = Id,
UserId = UserId,
TeacherId = TeacherId,
TeacherName = Teacher.Name,
Name = Name,
Description = Description,
StudentDisciplines = StudentDisciplines,

View File

@ -8,11 +8,11 @@ namespace UniversityRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class DisciplinesController : Controller
public class DisciplineController : Controller
{
private readonly ILogger _logger;
private readonly IDisciplineLogic _logic;
public DisciplinesController(IDisciplineLogic logic, ILogger<DisciplinesController> logger)
public DisciplineController(IDisciplineLogic logic, ILogger<DisciplineController> logger)
{
_logic = logic;
_logger = logger;