The next generation of the Teknik Services. Written in ASP.NET.
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 970B

12345678910111213141516171819202122232425262728293031323334
  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.Controllers;
  8. using Teknik.Models;
  9. namespace Teknik.Areas.Home.Controllers
  10. {
  11. public class HomeController : DefaultController
  12. {
  13. // GET: Home/Home
  14. private TeknikEntities db = new TeknikEntities();
  15. [AllowAnonymous]
  16. public ActionResult Index()
  17. {
  18. List<Post> lastPosts = new List<Post>();
  19. if (db.Posts.Count() > 10)
  20. {
  21. lastPosts = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).Take(10).ToList();
  22. }
  23. else if (db.Posts.Any())
  24. {
  25. lastPosts = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).ToList();
  26. }
  27. ViewBag.Title = Config.Title;
  28. return View(lastPosts);
  29. }
  30. }
  31. }