Files
newswebappTest/Views/news/Index.cshtml
2024-08-10 17:10:45 +03:30

76 lines
1.5 KiB
Plaintext

@using WebApplication1.Models
@model IEnumerable<newsModel>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
title
</th>
<th>
category
</th>
<th>
tag
</th>
<th>
publish date
</th>
<th>
publisher
</th>
<th>
Views
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.category)
</td>
<td>
@Html.DisplayFor(modelItem => item.tag)
</td>
<td>
@Html.DisplayFor(modelItem => item.date)
</td>
<td>
@Html.DisplayFor(modelItem => item.DisplayName)
</td>
<td>
@Html.DisplayFor(modelItem => item.views)
</td>
<td>
@Html.ActionLink("Read", "Details", new { id = item.NewsID })|
@if (ViewBag.role > 0 || ViewBag.uid == item.userID)
{
@Html.ActionLink("Edit", "Edit", new { id = item.NewsID })
<span>|</span>
@Html.ActionLink("Delete", "Delete", new { id = item.NewsID })
}
</td>
</tr>
}
</table>