public async Task <IHttpActionResult> PutTurfGroup(int id, TurfGroup turfGroup) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != turfGroup.Id) { return(BadRequest()); } db.Entry(turfGroup).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TurfGroupExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetTurfGroup(int id) { TurfGroup turfGroup = await db.TurfGroups.FindAsync(id); if (turfGroup == null) { return(NotFound()); } return(Ok(turfGroup)); }
public async Task <IHttpActionResult> PostTurfGroup(TurfGroup turfGroup) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TurfGroups.Add(turfGroup); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = turfGroup.Id }, turfGroup)); }
public async Task <IHttpActionResult> DeleteTurfGroup(int id) { TurfGroup turfGroup = await db.TurfGroups.FindAsync(id); if (turfGroup == null) { return(NotFound()); } db.TurfGroups.Remove(turfGroup); await db.SaveChangesAsync(); return(Ok(turfGroup)); }