public IHttpActionResult PutpotionIngredient(int id, potionIngredient potionIngredient) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != potionIngredient.id) { return(BadRequest()); } db.Entry(potionIngredient).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!potionIngredientExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetpotionIngredient(int id) { potionIngredient potionIngredient = db.potionIngredient.Find(id); if (potionIngredient == null) { return(NotFound()); } return(Ok(potionIngredient)); }
public IHttpActionResult PostpotionIngredient(potionIngredient potionIngredient) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.potionIngredient.Add(potionIngredient); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = potionIngredient.id }, potionIngredient)); }
public IHttpActionResult DeletepotionIngredient(int id) { potionIngredient potionIngredient = db.potionIngredient.Find(id); if (potionIngredient == null) { return(NotFound()); } db.potionIngredient.Remove(potionIngredient); db.SaveChanges(); return(Ok(potionIngredient)); }