//TODO: (erikpo) Should move the slug parameter and get call and null check up into a model binder public ActionResult Item(string blogSlug) { var correctedSlug = _blogSlugConstraint.FindSlug(blogSlug); if (correctedSlug == null) return new NotFoundResult(); var blog = _blogService.Get(correctedSlug); if (blog == null) return new NotFoundResult(); var model = new BlogViewModel { Blog = _services.ContentManager.BuildDisplayModel(blog, "Detail") }; _feedManager.Register(blog); return View(model); }
public ActionResult GetHomePage(int itemId) { var blog = _blogService.Get().Where(x => x.Id == itemId).FirstOrDefault(); if (blog == null) return new NotFoundResult(); var correctedSlug = _blogSlugConstraint.FindSlug(blog.Slug); if (correctedSlug == null) return new NotFoundResult(); blog = _blogService.Get(correctedSlug); if (blog == null) return new NotFoundResult(); var model = new BlogViewModel { Blog = Services.ContentManager.BuildDisplayModel(blog, "Detail") }; _feedManager.Register(blog); return new ViewResult { ViewName = "~/Modules/Orchard.Blogs/Views/Blog/Item.ascx", ViewData = new ViewDataDictionary<BlogViewModel>(model) }; }