Exemple #1
0
 private bool IsSinglePost(PostLinkViewModel model, IEnumerable<Post> posts)
 {
     if (model.Year != 0
         && model.Month != 0
         && model.Day != 0
         && !string.IsNullOrEmpty(model.Link)
         && posts.Count() == 1)
     {
         return true;
     }
     return false;
 }
Exemple #2
0
        public virtual ActionResult Show(PostLinkViewModel postLinkViewModel)
        {
            var postsViewModel = new PostsViewModel { Nickname = postLinkViewModel.Nickname };
            IList<Post> posts = _postService.GetBlogPosts(postLinkViewModel.Year, postLinkViewModel.Month,
                                                          postLinkViewModel.Day, postLinkViewModel.Nickname,
                                                          postLinkViewModel.Link);

            var modelStateDictionary = TempData["comment"] as ModelStateDictionary;

            if (modelStateDictionary != null)
            {
                ViewData.ModelState.Merge(modelStateDictionary);
            }

            return GetPosts(postLinkViewModel, posts, postsViewModel);
        }
Exemple #3
0
 private ActionResult GetPosts(PostLinkViewModel model, IList<Post> posts, PostsViewModel postsViewModel)
 {
     if (IsSinglePost(model, posts))
     {
         postsViewModel.ShowComments = true;
     }
     postsViewModel.AddPosts(posts);
     return View("Show", postsViewModel);
 }