예제 #1
0
 public ActionResult Create(Guid entryID)
 {
     var newComment = new Comment();
     var entry = _entryService.GetEntry(entryID);
     newComment.Entry = entry;
     return PartialView(newComment);
 }
예제 #2
0
 public ActionResult Create(Comment comment)
 {
     try
     {
         //if (ModelState.IsValid)
         //{
             comment.Entry = _entryService.GetEntry(/*id*/comment.Entry.ID);
             comment.User = _userService.GetUser(_userService.GetUser(User.Identity.Name).ID);
             _commentService.CreateComment(comment);
             return RedirectToAction("Entry", "Entry", new { id = comment.Entry.ID });
             //return View("~/Views/Entry/Entry.cshtml");
         //}
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Произошла ошибка. Невозможно добавить запись.");
     }
     return View();
 }
 public ActionResult EditComment(Comment model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var commentToUpdate = _commentService.GetComment(model.ID);
             commentToUpdate.Title = model.Title;
             commentToUpdate.CommentBody = model.CommentBody;
             _commentService.UpdateComment(commentToUpdate);
             return RedirectToAction("Comments", "Administrator", new { id = commentToUpdate.Entry.ID });
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Unable to edit comment. Please correct the errors and try again.");
     }
     return View("EditComment");
 }
예제 #4
0
 public void UpdateComment(Comment comment)
 {
     _commentRepository.Update(comment);
 }
예제 #5
0
 public void CreateComment(Comment comment)
 {
     _commentRepository.Create(comment);
 }