From d05ffc59a558fa57a31ce9b1e6deab622f131914 Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Thu, 17 Dec 2015 15:22:33 -0800 Subject: [PATCH] Fixed links and hiding non-published articles in main view --- Teknik/Areas/About/Views/About/Index.cshtml | 2 +- Teknik/Areas/Home/Controllers/HomeController.cs | 11 +++-------- Teknik/Areas/Home/Views/Home/Index.cshtml | 6 +++--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Teknik/Areas/About/Views/About/Index.cshtml b/Teknik/Areas/About/Views/About/Index.cshtml index ab382f1..38f3775 100644 --- a/Teknik/Areas/About/Views/About/Index.cshtml +++ b/Teknik/Areas/About/Views/About/Index.cshtml @@ -21,7 +21,7 @@

@Html.ActionLink("Personal Git Repositories", "Index", "Git", new { area = "Git" }, null)

-

@Html.ActionLink("Personal Blog", "Index", "Blog", new { area = "Blog" }, null)

+

@Html.ActionLink("Personal Blog", "Blog", "Blog", new { area = "Blog" }, null)

@Html.ActionLink("Entertaining Podcasts", "Index", "Podcast", new { area = "Podcast" }, null)

@Html.ActionLink("Mumble Server", "Mumble", "Help", new { area = "Help" }, null)

@Html.ActionLink("Full Transparency", "Index", "Transparency", new { area = "Transparency" }, null)

diff --git a/Teknik/Areas/Home/Controllers/HomeController.cs b/Teknik/Areas/Home/Controllers/HomeController.cs index f927aca..555b9af 100644 --- a/Teknik/Areas/Home/Controllers/HomeController.cs +++ b/Teknik/Areas/Home/Controllers/HomeController.cs @@ -18,14 +18,9 @@ namespace Teknik.Areas.Home.Controllers public ActionResult Index() { List lastPosts = new List(); - if (db.Posts.Count() > 10) - { - lastPosts = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).Take(10).ToList(); - } - else if (db.Posts.Any()) - { - lastPosts = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).ToList(); - } + var found = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).Where(p => p.Published).Take(10); + if (found != null) + lastPosts = found.ToList(); ViewBag.Title = Config.Title; return View(lastPosts); diff --git a/Teknik/Areas/Home/Views/Home/Index.cshtml b/Teknik/Areas/Home/Views/Home/Index.cshtml index 733185b..02c2e9b 100644 --- a/Teknik/Areas/Home/Views/Home/Index.cshtml +++ b/Teknik/Areas/Home/Views/Home/Index.cshtml @@ -90,7 +90,7 @@
- +

@@ -137,10 +137,10 @@
-

@post.Title +

@post.Title