public async Task <IHttpActionResult> PutBetComment(int id, BetComment betComment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != betComment.Id) { return(BadRequest()); } db.Entry(betComment).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BetCommentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetBetComment(int id) { BetComment betComment = await db.BetComments.FindAsync(id); if (betComment == null) { return(NotFound()); } return(Ok(betComment)); }
public async Task <IHttpActionResult> PostBetComment(BetComment betComment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } betComment.ApplicationUserId = User.Identity.GetUserId(); db.BetComments.Add(betComment); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = betComment.Id }, betComment)); }
public async Task <IHttpActionResult> DeleteBetComment(int id) { BetComment betComment = await db.BetComments.FindAsync(id); if (betComment == null) { return(NotFound()); } db.BetComments.Remove(betComment); await db.SaveChangesAsync(); return(Ok(betComment)); }