public async Task <IHttpActionResult> PutOfficeClass(int id, OfficeClass officeClass) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != officeClass.Id) { return(BadRequest()); } db.Entry(officeClass).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OfficeClassExists(id)) { return(Content(HttpStatusCode.NotFound, "The Office with Id " + id + " does not exist ")); //return NotFound(); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutOfficeClass(int id, OfficeClass officeClass) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != officeClass.Id) { return(BadRequest()); } db.Entry(officeClass).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OfficeClassExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }