public ActionResult GetThumbnails (int? page=1)
 {
     using (DbEntity db = new DbEntity())
     {
         //TODO: create thumbnail table
     }
         return null;
 }
 private IQueryable<Post> GetResults(string searchText, DbEntity db)
 {
     return db.Posts
                .Where(p => p.Title.Contains(searchText))
                .Select(pr => new Post
                {
                    Title = pr.Title,
                    CategoryName = pr.Categories.CategoryName,
                    Text = pr.Text,
                    CreationDate = pr.UpdateDate ?? pr.CreationDate,
                    Id = pr.Id
                }).AsQueryable();
 }
        public ActionResult Search(string searchText, int? page = 1)
        {
            var result = new SearchResult();
            using (DbEntity db = new DbEntity())
            {
                var posts = this.GetResults(searchText, db);

                result.TotalResults = posts.Count();
                result.Posts = posts
                               .Skip((page.Value - 1) * 5)
                               .Take(5).ToList();
            }

            return View(result);
        }
        public ActionResult Index()
        {
            var lastPost = new Post();

            using (DbEntity db = new DbEntity())
            {
                var post = db.Posts
                           .OrderByDescending(p => (p.UpdateDate.HasValue ? p.UpdateDate : p.CreationDate))
                           .Select(p => new Post
                           {
                               Id = p.Id,
                               Title = p.Title,
                               Text = p.Text,
                               CreationDate = p.UpdateDate ?? p.CreationDate,
                               CategoryName = p.Categories.CategoryName,
                              // Images = postimages
                           })
                           .First();
            }

            return View(lastPost);
        }