public IHttpActionResult PutMaterialInStore(int id, MaterialInStore materialInStore) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != materialInStore.Id) { return(BadRequest()); } db.Entry(materialInStore).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MaterialInStoreExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetMaterialInStore(int id) { MaterialInStore materialInStore = db.MaterialInStores.Find(id); if (materialInStore == null) { return(NotFound()); } return(Ok(materialInStore)); }
public IHttpActionResult PostMaterialInStore(MaterialInStore materialInStore) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.MaterialInStores.Add(materialInStore); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = materialInStore.Id }, materialInStore)); }
public IHttpActionResult DeleteMaterialInStore(int id) { MaterialInStore materialInStore = db.MaterialInStores.Find(id); if (materialInStore == null) { return(NotFound()); } db.MaterialInStores.Remove(materialInStore); db.SaveChanges(); return(Ok(materialInStore)); }