示例#1
0
 public ActionResult EditComment(EditCommentViewModel model)
 {
     if (ModelState.IsValid)
     {
         model.Text = model.Text.Replace(Environment.NewLine, "<br />");
         int questionId = repository.EditComment(model);
         return RedirectToAction("Question", new { id = questionId });
     }
     return View(model);
 }
示例#2
0
        public ActionResult EditComment(int? id)
        {
            if(id == null)
                return RedirectToAction("DisplayErrorMessage", "Error", new { message = "Der opstod en fejl under operationen. Prøv venlig igen eller " +
                                                                                        "kontakt en administrator"});
            Comment comment = repository.GetComment(id);
            if(comment == null)
                return RedirectToAction("DisplayErrorMessage", "Error", new { message = "Der opstod en fejl under operationen. Prøv venlig igen eller " +
                                                                                        "kontakt en administrator"});

            EditCommentViewModel model = new EditCommentViewModel
            {
                CommentId = comment.Id,
                Text = new Regex("<(.|\n)+?>").Replace(comment.Text, "\n")
            };

            return View(model);
        }