public IHttpActionResult PostControlDates(ControlDates controlDates) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ControlDates.Add(controlDates); try { db.SaveChanges(); } catch (DbUpdateException) { if (ControlDatesExists(controlDates.ControlId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = controlDates.ControlId }, controlDates)); }
public IHttpActionResult PutControlDates(int id, ControlDates controlDates) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != controlDates.ControlId) { return(BadRequest()); } db.Entry(controlDates).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ControlDatesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetControlDates(int id) { ControlDates controlDates = db.ControlDates.Find(id); if (controlDates == null) { return(NotFound()); } return(Ok(controlDates)); }
public IHttpActionResult DeleteControlDates(int id) { ControlDates controlDates = db.ControlDates.Find(id); if (controlDates == null) { return(NotFound()); } db.ControlDates.Remove(controlDates); db.SaveChanges(); return(Ok(controlDates)); }