public async Task <IHttpActionResult> PostKeycodeBan(KeycodeBan keycodeBan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.KeycodeBans.Add(keycodeBan); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (KeycodeBanExists(keycodeBan.KeycodeId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = keycodeBan.KeycodeId }, keycodeBan)); }
public async Task <IHttpActionResult> PutKeycodeBan(string id, KeycodeBan keycodeBan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != keycodeBan.KeycodeId) { return(BadRequest()); } db.Entry(keycodeBan).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KeycodeBanExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetKeycodeBan(string id) { KeycodeBan keycodeBan = await db.KeycodeBans.FindAsync(id); if (keycodeBan == null) { return(NotFound()); } return(Ok(keycodeBan)); }
public async Task <IHttpActionResult> DeleteKeycodeBan(string id) { KeycodeBan keycodeBan = await db.KeycodeBans.FindAsync(id); if (keycodeBan == null) { return(NotFound()); } db.KeycodeBans.Remove(keycodeBan); await db.SaveChangesAsync(); return(Ok(keycodeBan)); }