public IHttpActionResult PutCarguide(int id, Carguide carguide) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != carguide.CarguideId) { return(BadRequest()); } db.Entry(carguide).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CarguideExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCarguide(int id) { Carguide carguide = db.Carguides.Find(id); if (carguide == null) { return(NotFound()); } return(Ok(carguide)); }
public IHttpActionResult PostCarguide(Carguide carguide) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Carguides.Add(carguide); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = carguide.CarguideId }, carguide)); }
public IHttpActionResult DeleteCarguide(int id) { Carguide carguide = db.Carguides.Find(id); if (carguide == null) { return(NotFound()); } db.Carguides.Remove(carguide); db.SaveChanges(); return(Ok(carguide)); }