Exemplo n.º 1
0
        public IActionResult Details(int id)
        {
            if (!_context.Blogs.Any(blog => blog.Id == id))
            {
                return(PartialView("ErrorPage"));
            }
            BlogDetailsVM viewModel = new BlogDetailsVM
            {
                Blog  = _context.Blogs.Where(b => b.Id == id).FirstOrDefault(),
                Blogs = _context.Blogs.OrderByDescending(b => b.UpdatedDate).Take(5)
            };

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Details(int id)
        {
            if (!_db.Blogs.Any(b => b.Id == id))
            {
                return(PartialView("ErrorPage"));
            }
            BlogDetailsVM blog = new BlogDetailsVM
            {
                Blog             = await _db.Blogs.FindAsync(id),
                BlogDetailImages = _db.BlogDetailImages.Where(image => image.BlogId == id)
            };

            //ViewBag.Banner = _db.SectionBanners.Where(b => b.SectionName == "Blog Details").FirstOrDefault().ImageUrl;
            return(View(blog));
        }
        public IActionResult Details(int?id)
        {
            TempData["controllerName"] = this.ControllerContext.RouteData.Values["controller"].ToString();

            BlogDetailsVM blogDetailsVM = new BlogDetailsVM
            {
                BlogBanner  = _context.BlogBanners.Where(bb => bb.IsDeleted == false).FirstOrDefault(),
                Categories  = _context.Categories.Where(ctg => ctg.IsDeleted == false).ToList(),
                Tags        = _context.Tags.Where(t => t.IsDeleted == false).ToList(),
                BlogDetails = _context.BlogDetails.Where(bd => bd.IsDeleted == false && bd.LatestFromBlogId == id)
                              .Include(bd => bd.LatestFromBlog).ToList(),
                LatestFromBlogs = _context.LatestFromBlogs.Where(lfb => lfb.IsDeleted == false && lfb.Id == id)
                                  .Include(lfb => lfb.BlogDetail).Take(3).ToList()
            };

            return(View(blogDetailsVM));
        }