Example #1
0
 public ActionResult CreateComment(string id)
 {
     var aPost = _dataRepository.GetAPostWithId(id);
     var vm = new CommentViewModel();
     vm.ThePost = aPost;
     vm.ThePostId = id;
     return View("CreatePostComment", vm);
 }
Example #2
0
 public void AddComment(CommentViewModel aCommentvm)
 {
     var thePost = GetAPostWithId(aCommentvm.ThePostId);
     var aNewComment = new Comment
     {
         Body = aCommentvm.Body,
         Email = aCommentvm.Email,
         TimePosted = DateTime.Now
     };
     thePost.Comments.Add(aNewComment);
     _collection.Save(thePost);
 }
Example #3
0
 public ActionResult CreateComment(CommentViewModel vm)
 {
     try
     {
         vm.TimePosted = DateTime.Now;
         _dataRepository.AddComment(vm);
         //Post aPost =_dataRepository.GetAPostWithId(postId);
         return RedirectToAction("Details", new {id = vm.ThePostId});
     }
     catch
     {
         return View("Index");
     }
 }