public CocktailIngredient EditCocktailIngredient(CocktailIngredient ci) { using (var connection = new SqlConnection(Settings.GetConnectionString())) { var p = new DynamicParameters(); p.Add("CocktailId", ci.CocktailId); p.Add("IngredientId", ci.IngredientId); p.Add("Amount", ci.Amount); p.Add("CocktailIngredientId", ci.CocktailIngredientId); connection.Execute("CocktailIngredientAdd", p, commandType: CommandType.StoredProcedure); return ci; } }
public CocktailIngredient AddCocktailIngredient(CocktailIngredient ci) { using (var connection = new SqlConnection(Settings.GetConnectionString())) { var p = new DynamicParameters(); p.Add("CocktailId", ci.CocktailId); p.Add("IngredientId", ci.IngredientId); p.Add("Amount", ci.Amount); p.Add("CocktailIngredientId", dbType: DbType.Int32, direction: ParameterDirection.Output); connection.Execute("CocktailIngredientAdd", p, commandType: CommandType.StoredProcedure); ci.CocktailIngredientId = p.Get<int>("CocktailIngredientId"); return ci; } }