public IHttpActionResult PostControlSchedule(Models.ControlSchedule controlSchedule) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ControlSchedules.Add(controlSchedule); try { db.SaveChanges(); } catch (DbUpdateException) { if (ControlScheduleExists(controlSchedule.ControlSchedule_ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = controlSchedule.ControlSchedule_ID }, controlSchedule)); }
public IHttpActionResult PutControlSchedule(int id, Models.ControlSchedule controlSchedule) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != controlSchedule.ControlSchedule_ID) { return(BadRequest()); } db.Entry(controlSchedule).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ControlScheduleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetControlSchedule(int id) { Models.ControlSchedule controlSchedule = db.ControlSchedules.Find(id); if (controlSchedule == null) { return(NotFound()); } return(Ok(controlSchedule)); }
public IHttpActionResult DeleteControlSchedule(int id) { Models.ControlSchedule controlSchedule = db.ControlSchedules.Find(id); if (controlSchedule == null) { return(NotFound()); } db.ControlSchedules.Remove(controlSchedule); db.SaveChanges(); return(Ok(controlSchedule)); }