public async Task <IHttpActionResult> PostSoftwareBan(SoftwareBan softwareBan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SoftwareBans.Add(softwareBan); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (SoftwareBanExists(softwareBan.TokenId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = softwareBan.TokenId }, softwareBan)); }
public async Task <IHttpActionResult> PutSoftwareBan(string id, SoftwareBan softwareBan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != softwareBan.TokenId) { return(BadRequest()); } db.Entry(softwareBan).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SoftwareBanExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetSoftwareBan(string id) { SoftwareBan softwareBan = await db.SoftwareBans.FindAsync(id); if (softwareBan == null) { return(NotFound()); } return(Ok(softwareBan)); }
public async Task <IHttpActionResult> DeleteSoftwareBan(string id) { SoftwareBan softwareBan = await db.SoftwareBans.FindAsync(id); if (softwareBan == null) { return(NotFound()); } db.SoftwareBans.Remove(softwareBan); await db.SaveChangesAsync(); return(Ok(softwareBan)); }