public IHttpActionResult PostDeleveryMethod(DeleveryMethod deleveryMethod) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DeleveryMethods.Add(deleveryMethod); try { db.SaveChanges(); } catch (DbUpdateException) { if (DeleveryMethodExists(deleveryMethod.ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = deleveryMethod.ID }, deleveryMethod)); }
public IHttpActionResult PutDeleveryMethod(int id, DeleveryMethod deleveryMethod) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != deleveryMethod.ID) { return(BadRequest()); } db.Entry(deleveryMethod).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DeleveryMethodExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetDeleveryMethod(int id) { DeleveryMethod deleveryMethod = db.DeleveryMethods.Find(id); if (deleveryMethod == null) { return(NotFound()); } return(Ok(deleveryMethod)); }
public IHttpActionResult DeleteDeleveryMethod(int id) { DeleveryMethod deleveryMethod = db.DeleveryMethods.Find(id); if (deleveryMethod == null) { return(NotFound()); } db.DeleveryMethods.Remove(deleveryMethod); db.SaveChanges(); return(Ok(deleveryMethod)); }