public IHttpActionResult PostSchoolShift(SchoolShift schoolShift) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SchoolShifts.Add(schoolShift); try { db.SaveChanges(); } catch (DbUpdateException) { if (SchoolShiftExists(schoolShift.SchoolShift1)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = schoolShift.SchoolShift1 }, schoolShift)); }
public IHttpActionResult PutSchoolShift(string id, SchoolShift schoolShift) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != schoolShift.SchoolShift1) { return(BadRequest()); } db.Entry(schoolShift).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SchoolShiftExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetSchoolShift(string id) { SchoolShift schoolShift = db.SchoolShifts.Find(id); if (schoolShift == null) { return(NotFound()); } return(Ok(schoolShift)); }
public IHttpActionResult DeleteSchoolShift(string id) { SchoolShift schoolShift = db.SchoolShifts.Find(id); if (schoolShift == null) { return(NotFound()); } db.SchoolShifts.Remove(schoolShift); db.SaveChanges(); return(Ok(schoolShift)); }