public List <Category> GetTopCategories() { List <Category> categoriesList = new List <Category>(); _executerCategoryCmd executer = new _executerCategoryCmd(ExecuteCategorySqlCmd); using (SqlConnection sqlConnection = new SqlConnection(_connectionString)) { using (SqlCommand cmd = new SqlCommand("GetTopCategories", sqlConnection)) { cmd.CommandType = CommandType.StoredProcedure; categoriesList = executer(sqlConnection, cmd); } } return(categoriesList); }
public List <Category> GetChildCategoriesById(int categoryId) { List <Category> categoriesList = new List <Category>(); if (categoryId > 0) { _executerCategoryCmd executer = new _executerCategoryCmd(ExecuteCategorySqlCmd); using (SqlConnection sqlConnection = new SqlConnection(_connectionString)) { using (SqlCommand cmd = new SqlCommand("GetChildCategoriesById", sqlConnection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CategoryId", categoryId); categoriesList = executer(sqlConnection, cmd); } } } return(categoriesList); }
public Category GetCategoryById(int categoryId) { Category category = new Category(); if (categoryId > 0) { _executerCategoryCmd executer = new _executerCategoryCmd(ExecuteCategorySqlCmd); using (SqlConnection sqlConnection = new SqlConnection(_connectionString)) { using (SqlCommand cmd = new SqlCommand("GetCategoryById", sqlConnection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CategoryId", categoryId); category = executer(sqlConnection, cmd).FirstOrDefault(); } } } return(category); }