public IHttpActionResult PutCommentTransport(int id, CommentTransport commentTransport) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != commentTransport.CommentID) { return(BadRequest()); } db.Entry(commentTransport).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CommentTransportExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostCommentTransport(CommentTransport commentTransport) { db.CommentTransports.Add(commentTransport); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = commentTransport.CommentID }, commentTransport)); }
public IHttpActionResult DeleteCommentTransport(int id) { CommentTransport commentTransport = db.CommentTransports.Find(id); if (commentTransport == null) { return(NotFound()); } db.CommentTransports.Remove(commentTransport); db.SaveChanges(); return(Ok(commentTransport)); }
public IHttpActionResult Post(CreateCommentViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var comment = new CommentTransport { Content = model.Content, UserId = model.UserId, ExecutorId = model.ExecutorId }; //var comment = Mapper.Map<CreateCommentViewModel, CommentTransport>(model); CommentManager.CreateComment(comment); return(Ok()); }