Пример #1
0
        public ViewResult Post(int year, int month, string title)
        {
            var post = _blogRepository.Post(year, month, title);

            if (post == null)
            {
                throw new HttpException(404, "Post not found");
            }

            if (post.Published == false && User.Identity.IsAuthenticated == false)
            {
                throw new HttpException(401, "The post is not published");
            }

            return(View(post));
        }
Пример #2
0
 public PhotoViewModel(int year, int month, string title, IPhoto photoRepository, IPosts blogRepository)
 {
     LatestPosts = blogRepository.Post(year, month, title);
     if (LatestPosts != null)
     {
         var post = mapping.GetPostsById(LatestPosts.id);
         if (post.Album != null)
         {
             Photos = photoRepository.PhotosForAlbum(post.Album.id);
         }
     }
 }
Пример #3
0
        public ActionResult GoToPost(Guid id)
        {
            var post = _blogRepository.Post(id);

            return(RedirectToRoute(new { controller = "Blog", action = "Post", year = post.CreatedOn.Year, month = post.CreatedOn.Month, title = post.UrlSlug }));
        }