public DTOTacoIngredient Delete(int id) { DTOTacoIngredient exists = Get(id); _repo.Delete(id); return(exists); }
public DTOTacoIngredient Create(DTOTacoIngredient newTacoIngredient) { int id = _repo.Create(newTacoIngredient); newTacoIngredient.Id = id; return(newTacoIngredient); }
public DTOTacoIngredient Get(int Id) { DTOTacoIngredient exists = _repo.GetById(Id); if (exists == null) { throw new Exception("Invalid tacoingredient mi amigo"); } return(exists); }
public ActionResult <DTOTacoIngredient> Post([FromBody] DTOTacoIngredient newDTOTacoIngredient) { try { return(Ok(_service.Create(newDTOTacoIngredient))); } catch (Exception e) { return(BadRequest(e.Message)); } }
internal int Create(DTOTacoIngredient newDTOTacoIngredient) { string sql = @" INSERT INTO tacoingredients (tacoId, ingId) VALUES (@TacoId, @IngId); SELECT LAST_INSERT_ID();"; return(_db.ExecuteScalar <int>(sql, newDTOTacoIngredient)); }