public ActionResult Create(Comment comment) { var commentData = CommentMapper.Map(comment); commentRepository.Create(commentData); return RedirectToRoute("NoteDetails", new { id = comment.NoteId }); }
public ActionResult Add(object o) { var userRepo = new UserRepository(); Comment comment = new Comment(); var str = o.ToString(); JObject obj = JObject.Parse(str); var userId = (int)obj.SelectToken("UserId"); comment.Author = UserMapper.Map(userRepo.Get(userId)); comment.Text = (string)obj.SelectToken("Text"); comment.NoteId = (int)obj.SelectToken("NoteId"); comment.CreatedOn = DateTime.Now; commentRepository.Create(CommentMapper.Map(comment)); return new HttpStatusCodeResult(HttpStatusCode.OK); }