public ActionResult Patch(long id, [FromBody] CommentCreationViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var comm = _commentRepository.GetSingle(s => s.Id == id); comm.Content = model.Content; _commentRepository.Update(comm); _commentRepository.Commit(); _logger.LogInfo("Yorum güncellendi " + id + ". "); return(NoContent()); }
public ActionResult <CommentViewModel> Post([FromBody] CommentCreationViewModel model) { var creationTime = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds(); var comm = new Model.Comment { BlogId = model.BlogId, UserId = NVLInt64(HttpContext.User.Identity.Name, 0), Content = model.Content, CreationTime = creationTime, }; _commentRepository.Add(comm); _commentRepository.Commit(); return(_mapper.Map <Model.Comment, CommentViewModel>(comm)); }