Ejemplo n.º 1
0
 public ActionResult GetThumbnails (int? page=1)
 {
     using (DbEntity db = new DbEntity())
     {
         //TODO: create thumbnail table
     }
         return null;
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }