count news
This commit is contained in:
@ -13,6 +13,8 @@ namespace WebApplication1.Controllers
|
|||||||
|
|
||||||
public ActionResult Index()
|
public ActionResult Index()
|
||||||
{
|
{
|
||||||
|
ViewBag.newsCount = db.news.Count();
|
||||||
|
ViewBag.views = "";
|
||||||
setTitle();
|
setTitle();
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,14 +10,14 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<section class="col-md-4" aria-labelledby="gettingStartedTitle">
|
<section class="col-md-4" aria-labelledby="newsTitleDisplay">
|
||||||
<h2 id="gettingStartedTitle">Getting started</h2>
|
<h2 id="newsTitleDisplay">News count</h2>
|
||||||
<p>
|
<p>
|
||||||
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
|
@ViewBag.newsCount
|
||||||
enables a clean separation of concerns and gives you full control over markup
|
</p>
|
||||||
for enjoyable, agile development.
|
<p>
|
||||||
|
<a class="btn btn-outline-dark" href="/news"> Start Reading »</a>
|
||||||
</p>
|
</p>
|
||||||
<p><a class="btn btn-outline-dark" href="https://go.microsoft.com/fwlink/?LinkId=301865">Learn more »</a></p>
|
|
||||||
</section>
|
</section>
|
||||||
<section class="col-md-4" aria-labelledby="librariesTitle">
|
<section class="col-md-4" aria-labelledby="librariesTitle">
|
||||||
<h2 id="librariesTitle">Get more libraries</h2>
|
<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\Details.cshtml" />
|
||||||
<Content Include="Views\tags\Edit.cshtml" />
|
<Content Include="Views\tags\Edit.cshtml" />
|
||||||
<Content Include="Views\tags\Index.cshtml" />
|
<Content Include="Views\tags\Index.cshtml" />
|
||||||
|
<Content Include="Views\news\Latest.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
|
|||||||
Reference in New Issue
Block a user