count news

This commit is contained in:
2024-08-01 17:28:00 +03:30
parent d73b5dc266
commit fbb2d406cb
4 changed files with 61 additions and 6 deletions

View File

@ -10,14 +10,14 @@
</section>
<div class="row">
<section class="col-md-4" aria-labelledby="gettingStartedTitle">
<h2 id="gettingStartedTitle">Getting started</h2>
<section class="col-md-4" aria-labelledby="newsTitleDisplay">
<h2 id="newsTitleDisplay">News count</h2>
<p>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and gives you full control over markup
for enjoyable, agile development.
@ViewBag.newsCount
</p>
<p>
<a class="btn btn-outline-dark" href="/news"> Start Reading &raquo;</a>
</p>
<p><a class="btn btn-outline-dark" href="https://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p>
</section>
<section class="col-md-4" aria-labelledby="librariesTitle">
<h2 id="librariesTitle">Get more libraries</h2>

52
Views/news/Latest.cshtml Normal file
View File

@ -0,0 +1,52 @@
@model IEnumerable<WebApplication1.Models.news>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.title)
</th>
<th>
category
</th>
<th>
@Html.DisplayNameFor(model => model.tag)
</th>
<th>
@Html.DisplayNameFor(model => model.publishDate)
</th>
<th>
@Html.DisplayNameFor(model => model.views)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.title)
</td>
<td>
@Html.DisplayFor(modelItem => item.cat)
</td>
<td>
@Html.DisplayFor(modelItem => item.tag)
</td>
<td>
@Html.DisplayFor(modelItem => item.publishDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.views)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
</td>
</tr>
}
</table>