public IHttpActionResult PutMechanicProfile(int id, MechanicProfile mechanicProfile) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mechanicProfile.Id) { return(BadRequest()); } db.Entry(mechanicProfile).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MechanicProfileExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetMechanicProfile(int id) { MechanicProfile mechanicProfile = db.MechanicProfiles.Find(id); if (mechanicProfile == null) { return(NotFound()); } return(Ok(mechanicProfile)); }
public IHttpActionResult PostMechanicProfile(MechanicProfile mechanicProfile) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.MechanicProfiles.Add(mechanicProfile); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = mechanicProfile.Id }, mechanicProfile)); }
public IHttpActionResult DeleteMechanicProfile(int id) { MechanicProfile mechanicProfile = db.MechanicProfiles.Find(id); if (mechanicProfile == null) { return(NotFound()); } db.MechanicProfiles.Remove(mechanicProfile); db.SaveChanges(); return(Ok(mechanicProfile)); }