public IHttpActionResult PutAllowedViolations(int id, AllowedViolations allowedViolations) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != allowedViolations.ID) { return(BadRequest()); } db.Entry(allowedViolations).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AllowedViolationsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// PUT api/AllowedViolationsWorkflow/5 public IHttpActionResult PutAllowedViolationsWorkflow(int id, AllowedViolationsWorkflow allowedviolationsworkflow) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != allowedviolationsworkflow.ID) { return(BadRequest()); } db.Entry(allowedviolationsworkflow).State = EntityState.Modified; try { AllowedViolations allowViolation = db.AllowedViolations.Find(allowedviolationsworkflow.ViolationId); db.Entry(allowViolation).State = EntityState.Modified; allowViolation.Status = allowedviolationsworkflow.Step; db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AllowedViolationsWorkflowExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetAllowedViolations(int id) { AllowedViolations allowedViolations = db.AllowedViolations.Find(id); if (allowedViolations == null) { return(NotFound()); } return(Ok(allowedViolations)); }
public IHttpActionResult PostAllowedViolations(AllowedViolations allowedViolations) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AllowedViolations.Add(allowedViolations); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = allowedViolations.ID }, allowedViolations)); }
public IHttpActionResult DeleteAllowedViolations(int id) { AllowedViolations allowedViolations = db.AllowedViolations.Find(id); if (allowedViolations == null) { return(NotFound()); } db.AllowedViolations.Remove(allowedViolations); db.SaveChanges(); return(Ok(allowedViolations)); }