Exemplo n.º 1
0
        public List <RecipeView> GetRecipes()
        {
            _executerRecipeViewCmd executer    = new _executerRecipeViewCmd(ExecuteRecipeViewSqlCmd);
            List <RecipeView>      recipesList = new List <RecipeView>();

            using (SqlConnection sqlConnection = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetRecipes", sqlConnection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    recipesList     = executer(sqlConnection, cmd);
                }
            }

            return(recipesList);
        }
Exemplo n.º 2
0
        public IEnumerable <RecipeView> GetRecipesByIngridientName(string ingridientName)
        {
            List <RecipeView> recipesList = new List <RecipeView>();

            if (!string.IsNullOrEmpty(ingridientName))
            {
                _executerRecipeViewCmd executer = new _executerRecipeViewCmd(ExecuteRecipeViewSqlCmd);

                using (SqlConnection sqlConnection = new SqlConnection(_connectionString))
                {
                    using (SqlCommand cmd = new SqlCommand("GetRecipesByIngridientName", sqlConnection))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@ingridientName", ingridientName);
                        recipesList = executer(sqlConnection, cmd);
                    }
                }
            }

            return(recipesList);
        }
Exemplo n.º 3
0
        public IEnumerable <RecipeView> GetRecipesByCategoryId(int categoryId)
        {
            List <RecipeView> recipesList = new List <RecipeView>();

            if (categoryId > 0)
            {
                _executerRecipeViewCmd executer = new _executerRecipeViewCmd(ExecuteRecipeViewSqlCmd);

                using (SqlConnection sqlConnection = new SqlConnection(_connectionString))
                {
                    using (SqlCommand cmd = new SqlCommand("GetRecipesByCategoryId", sqlConnection))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@CategoryId", categoryId);
                        recipesList = executer(sqlConnection, cmd);
                    }
                }
            }

            return(recipesList);
        }