Exemplo n.º 1
0
        public IActionResult EditBlogPost(string name)
        {
            var blogPost = _blogPostRepository.GetByTitle(name);

            if (blogPost == null)
            {
                return(NotFound());
            }

            var model = _mapper.Map <EditBlogPostViewModel>(blogPost);

            model.OldTitle             = model.Title;
            model.AvailableContentTags = _contentTagRepository.List().Select(s => s.Name).ToList();
            model.SelectedContentTags  =
                _blogPostRepository.GetContentTagsByBlogPostTitle(model.Title).Select(s => s.Name).ToList();

            return(View(model));
        }
Exemplo n.º 2
0
        public IActionResult BlogPost(string blogPostTitle)
        {
            BlogPostContentViewModel model;

            try
            {
                var blogPost = _blogPostRepository.GetByTitle(blogPostTitle);

                if (!blogPost.IsPublished)
                {
                    return(NotFound());
                }

                model             = _mapper.Map <BlogPostContentViewModel>(blogPost);
                model.ContentTags = _blogPostRepository.GetContentTagsByBlogPostTitle(model.Title);
            }
            catch (BlogPostNotFoundException)
            {
                //TODO: Log error
                return(NotFound());
            }

            return(View(model));
        }