public ActionResult NewComment(CommentViewModel model) { model.DatePosted = DateTime.Now; model.User = User.Identity.Name; model.id = Guid.NewGuid(); if (ModelState.IsValid && User.Identity.IsAuthenticated) { var newComment = ModelMapper.ModelToEntity(model); repo.AddOrUpdate(newComment); return(Content("Comment added")); } return(Content("Couldn't add comment")); }
public ActionResult NewComment(CommentViewModel model) { var identity = (ClaimsIdentity)User.Identity; var sid = identity.Claims.First(x => x.Type == ClaimTypes.Sid); model.UserID = int.Parse(sid.Value); model.DatePosted = DateTime.Now; if (ModelState.IsValid && User.Identity.IsAuthenticated) { var newComment = EntityModelMapper.ModelToEntity(model); repo.AddOrUpdate(newComment); return(Content("Comment added")); } return(Content("Couldn't add comment")); }
public bool AddOrUpdate(Comment comment) { return(_repo.AddOrUpdate(comment)); }
public void Post([FromBody] CommentModel model) { var entity = CommentModelToEntity(model); commentRepository.AddOrUpdate(entity); }