public Recipe EditRecipe(Recipe recipe) { using (var connection = new SqlConnection(Settings.GetConnectionString())) { var p = new DynamicParameters(); p.Add("@CocktailId", recipe.CocktailId); p.Add("@RecipeId", recipe.RecipeId); p.Add("@StepNumber", recipe.StepNumber); p.Add("@Text", recipe.Text); connection.Execute("RecipeEdit", p, commandType: CommandType.StoredProcedure); return recipe; } }
public Recipe AddRecipe(Recipe recipe) { using (var connection = new SqlConnection(Settings.GetConnectionString())) { var p = new DynamicParameters(); p.Add("@CocktailId", recipe.CocktailId); p.Add("@StepNumber", recipe.StepNumber); p.Add("@Text", recipe.Text); p.Add("@RecipeId", dbType: DbType.Int32, direction: ParameterDirection.Output); connection.Execute("RecipeAdd", p, commandType: CommandType.StoredProcedure); recipe.RecipeId = p.Get<int>("@RecipeId"); return recipe; } }