public IHttpActionResult PutToiletFacility(int id, ToiletFacility toiletFacility) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != toiletFacility.ToiletFacilities_id) { return(BadRequest()); } db.Entry(toiletFacility).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ToiletFacilityExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetToiletFacility(int id) { ToiletFacility toiletFacility = db.ToiletFacilities.Find(id); if (toiletFacility == null) { return(NotFound()); } return(Ok(toiletFacility)); }
public IHttpActionResult PostToiletFacility(ToiletFacility toiletFacility) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ToiletFacilities.Add(toiletFacility); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = toiletFacility.ToiletFacilities_id }, toiletFacility)); }
public IHttpActionResult DeleteToiletFacility(int id) { ToiletFacility toiletFacility = db.ToiletFacilities.Find(id); if (toiletFacility == null) { return(NotFound()); } db.ToiletFacilities.Remove(toiletFacility); db.SaveChanges(); return(Ok(toiletFacility)); }