public IHttpActionResult Put(int id, ECarriage eCarriage) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eCarriage.carriage_id) { return(BadRequest()); } db.Entry(eCarriage).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ECarriageExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Get(int id) { ECarriage eCarriage = db.ECarriages.Find(id); if (eCarriage == null) { return(NotFound()); } return(Ok(eCarriage)); }
public IHttpActionResult Post(ECarriage eCarriage) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ECarriages.Add(eCarriage); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = eCarriage.carriage_id }, eCarriage)); }
public IHttpActionResult Delete(int id) { ECarriage eCarriage = db.ECarriages.Find(id); if (eCarriage == null) { return(NotFound()); } db.ECarriages.Remove(eCarriage); db.SaveChanges(); return(Ok(eCarriage)); }