public async Task <IHttpActionResult> PutCommentsModal(int id, CommentsModal commentsModal) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != commentsModal.CommentId) { return(BadRequest()); } db.Entry(commentsModal).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentsModalExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetCommentsModal(int id) { CommentsModal commentsModal = await db.Comments.FindAsync(id); if (commentsModal == null) { return(NotFound()); } return(Ok(commentsModal)); }
public async Task <IHttpActionResult> PostCommentsModal(CommentsModal commentsModal) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } commentsModal.CommentCreatedDate = DateTime.Now; db.Comments.Add(commentsModal); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = commentsModal.CommentId }, commentsModal)); }
public async Task <IHttpActionResult> DeleteCommentsModal(int id) { CommentsModal commentsModal = await db.Comments.FindAsync(id); if (commentsModal == null) { return(NotFound()); } db.Comments.Remove(commentsModal); db.Entry(commentsModal).State = EntityState.Deleted; await db.SaveChangesAsync(); return(Ok(commentsModal)); }