예제 #1
0
 public virtual ActionResult Index(AdminBlogViewModel model)
 {
     var blog = _blogService.GetBlog(model.Nickname);
     IList<Post> posts = _postService.GetOrderedBlogPosts(blog.Id);
     var postsViewModel = new PostsViewModel(model.Nickname, posts);
     return View(postsViewModel);
 }
예제 #2
0
 public void GivenANewPostsCollection_WhenIAccessTheCollection_ThenItIsTheSameAsTheSetValue()
 {
     var posts = new List<PostViewModel>();
     var model = new PostsViewModel();
     model.Posts = posts;
     Assert.That(model.Posts, Is.EqualTo(posts));
 }
예제 #3
0
 public virtual ActionResult Index(string nickname)
 {
     var postsViewModel = new PostsViewModel { Nickname = nickname };
     IList<Post> posts = _postService.GetBlogPosts(nickname);
     postsViewModel.AddPosts(posts);
     return View(postsViewModel);
 }
예제 #4
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);
        }
예제 #5
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);
 }
예제 #6
0
 public void GivenAPostsViewModel_WhenIGetACollectionOfPostViewModels_ThenItIsInitialized()
 {
     var model = new PostsViewModel();
     List<PostViewModel> posts = model.Posts;
     Assert.That(posts, Is.Not.Null);
 }