Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetpotionIngredient(int id)
        {
            potionIngredient potionIngredient = db.potionIngredient.Find(id);

            if (potionIngredient == null)
            {
                return(NotFound());
            }

            return(Ok(potionIngredient));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }