public async Task <IHttpActionResult> PostPrimaryVariance(PrimaryVariance primaryVariance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PrimaryVariances.Add(primaryVariance); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (PrimaryVarianceExists(primaryVariance.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = primaryVariance.Id }, primaryVariance)); }
public async Task <IHttpActionResult> PutPrimaryVariance(int id, PrimaryVariance primaryVariance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != primaryVariance.Id) { return(BadRequest()); } db.Entry(primaryVariance).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrimaryVarianceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetPrimaryVariance(int id) { PrimaryVariance primaryVariance = await db.PrimaryVariances.FindAsync(id); if (primaryVariance == null) { return(NotFound()); } return(Ok(primaryVariance)); }
public async Task <IHttpActionResult> DeletePrimaryVariance(int id) { PrimaryVariance primaryVariance = await db.PrimaryVariances.FindAsync(id); if (primaryVariance == null) { return(NotFound()); } db.PrimaryVariances.Remove(primaryVariance); await db.SaveChangesAsync(); return(Ok(primaryVariance)); }