public ActionResult Add(FormCommentModel model) { commentManager.Add(model); switch (model.ParentType) { case CommentParentType.ALERT: return(RedirectToAction("AlertComments", new { alertId = model.ParentId })); case CommentParentType.COMMENT: return(RedirectToAction("CommentComments", new { commentId = model.ParentId })); default: return(Json(false)); } }
public void Add(FormCommentModel model) { Comment comment = new Comment { User = unitOfWork.UserRepository.Get(SessionParser.User.Id), Message = model.Message, RowDate = DateTime.Now }; switch (model.ParentType) { case CommentParentType.ALERT: comment.Alert = unitOfWork.AlertRepository.Get(model.ParentId); break; case CommentParentType.COMMENT: comment.ParentComment = unitOfWork.CommentRepository.Get(model.ParentId); break; } unitOfWork.CommentRepository.Add(comment); }