private ActionResult GetPosts(PostLinkViewModel model, IList <Post> posts, PostsViewModel postsViewModel) { if (IsSinglePost(model, posts)) { postsViewModel.ShowComments = true; } postsViewModel.AddPosts(posts); return(View("Show", postsViewModel)); }
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); }
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)); }