SUBD/ForumUserApp/Views/Home/Index.cshtml

59 lines
1.2 KiB
Plaintext

@using ForumContracts.ViewModels
@model List<CategoryViewModel>
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Главная страница</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateCategory">Создать категорию</a>
<a asp-action="CreateQuestion">Задать вопрос</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Имя категории
</th>
<th>
Описание категории
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
<form asp-action="Questions" method="post">
<input type="hidden" name="categoryId" value="@item.Id"/>
<button type="submit" class="btn btn-primary">Выбрать</button>
</form>
</td>
</tr>
}
</tbody>
</table>
}
</div>