The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HomeController.cs 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Teknik.Areas.Blog.Models;
  7. using Teknik.Areas.Home.ViewModels;
  8. using Teknik.Controllers;
  9. using Teknik.Helpers;
  10. using Teknik.Models;
  11. namespace Teknik.Areas.Home.Controllers
  12. {
  13. public class HomeController : DefaultController
  14. {
  15. // GET: Home/Home
  16. private TeknikEntities db = new TeknikEntities();
  17. [AllowAnonymous]
  18. public ActionResult Index()
  19. {
  20. HomeViewModel model = new HomeViewModel();
  21. // Grab the latest site blog posts
  22. List<Post> lastSite = new List<Post>();
  23. var foundSite = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).Where(p => p.Published && p.BlogId == Constants.SERVERBLOGID).Take(10);
  24. if (foundSite != null)
  25. lastSite = foundSite.ToList();
  26. // Grab the latest user blog posts
  27. List<Post> lastPosts = new List<Post>();
  28. var foundPosts = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).Where(p => p.Published).Take(10);
  29. if (foundPosts != null)
  30. lastPosts = foundPosts.ToList();
  31. // Grab the latest podcasts
  32. List<Post> lastPods = new List<Post>();
  33. model.SitePosts = lastSite;
  34. model.Podcasts = lastPods;
  35. model.BlogPosts = lastPods;
  36. ViewBag.Title = Config.Title;
  37. return View(model);
  38. }
  39. }
  40. }