public Ingredient EditIngredient(Ingredient ingredient) { using (var connection = new SqlConnection(Settings.GetConnectionString())) { var p = new DynamicParameters(); p.Add("IngredientId", ingredient.IngredientId); p.Add("Name", ingredient.Name); p.Add("IsLiquor", ingredient.IsLiquor); connection.Execute("IngredientEdit", p, commandType: CommandType.StoredProcedure); return ingredient; } }
public Ingredient AddIngredient(Ingredient ingredient) { using (var connection = new SqlConnection(Settings.GetConnectionString())) { var p = new DynamicParameters(); p.Add("Name", ingredient.Name); p.Add("IsLiquor", ingredient.IsLiquor); p.Add("IngredientId", dbType: DbType.Int32, direction: ParameterDirection.Output); connection.Execute("IngredientAdd", p, commandType: CommandType.StoredProcedure); ingredient.IngredientId = p.Get<int>("IngredientId"); return ingredient; } }