count news
This commit is contained in:
@ -13,6 +13,8 @@ namespace WebApplication1.Controllers
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewBag.newsCount = db.news.Count();
|
||||
ViewBag.views = "";
|
||||
setTitle();
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -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 »</a>
|
||||
</p>
|
||||
<p><a class="btn btn-outline-dark" href="https://go.microsoft.com/fwlink/?LinkId=301865">Learn more »</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
52
Views/news/Latest.cshtml
Normal 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>
|
||||
@ -275,6 +275,7 @@
|
||||
<Content Include="Views\tags\Details.cshtml" />
|
||||
<Content Include="Views\tags\Edit.cshtml" />
|
||||
<Content Include="Views\tags\Index.cshtml" />
|
||||
<Content Include="Views\news\Latest.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
|
||||
Reference in New Issue
Block a user