public IHttpActionResult PutInfraClass(int id, InfraClass infraClass) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != infraClass.InfraClasses_id) { return(BadRequest()); } db.Entry(infraClass).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!InfraClassExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetInfraClass(int id) { InfraClass infraClass = db.InfraClasses.Find(id); if (infraClass == null) { return(NotFound()); } return(Ok(infraClass)); }
public IHttpActionResult PostInfraClass(InfraClass infraClass) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.InfraClasses.Add(infraClass); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = infraClass.InfraClasses_id }, infraClass)); }
public IHttpActionResult DeleteInfraClass(int id) { InfraClass infraClass = db.InfraClasses.Find(id); if (infraClass == null) { return(NotFound()); } db.InfraClasses.Remove(infraClass); db.SaveChanges(); return(Ok(infraClass)); }