internal TacoIngredient Delete(int id)
        {
            TacoIngredient exists = Get(id);

            _repo.Delete(id);
            return(exists);
        }
        internal TacoIngredient Create(TacoIngredient newTacoIngredient)
        {
            int id = _repo.Create(newTacoIngredient);

            newTacoIngredient.Id = id;
            return(newTacoIngredient);
        }
        public TacoIngredient Get(int Id)
        {
            TacoIngredient exists = _repo.GetById(Id);

            if (exists == null)
            {
                throw new Exception("Invalid ingredient mi amigo");
            }
            return(exists);
        }
Ejemplo n.º 4
0
        internal int Create(TacoIngredient newTacoIngredient)
        {
            string sql = @"
        INSERT INTO tacoingredients
        (tacoId, ingredientId)
        VALUES
        (@TacoId, @IngredientId);
        SELECT LAST_INSERT_ID();";

            return(_db.ExecuteScalar <int>(sql, newTacoIngredient));
        }
Ejemplo n.º 5
0
 public ActionResult <TacoIngredient> Post([FromBody] TacoIngredient newTacoIngredient)
 {
     try
     {
         return(Ok(_service.Create(newTacoIngredient)));
     }
     catch (System.Exception e)
     {
         return(BadRequest(e.Message));
     }
 }