Ejemplo n.º 1
0
 public static CategoriesDataComponent.CategoriesDataTable GetParentCategoriesById(int categoryId)
 {
     using (CategoriesDataAdapter db = new CategoriesDataAdapter())
     {
         return db.GetParentCategoriesById(categoryId);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// InsertCategory
        /// </summary>
        /// <param name="parentCategoryId"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static int InsertCategory(int parentCategoryId, string name)
        {
            int? dbParentCategoryId = parentCategoryId;
            if (parentCategoryId == DefaultValues.CategoryIdMinValue)
                dbParentCategoryId = null;

            using (CategoriesDataAdapter db = new CategoriesDataAdapter())
            {
                return (int) db.InsertCategory(dbParentCategoryId, name);
            }
        }
Ejemplo n.º 3
0
        public static bool MoveCategory(int categoryId, int newParentCategoryId)
        {
            int returnValue = 0;

            if (categoryId != newParentCategoryId)
            {
                using (CategoriesDataAdapter db = new CategoriesDataAdapter())
                {
                    // if newParentCategoryId is 0, we move the category to the top level (ParentCategoryId becomes NULL)
                    if (newParentCategoryId == DefaultValues.IdNullValue)
                        returnValue = Convert.ToInt32(db.MoveCategory(categoryId, null));
                    else
                        returnValue = Convert.ToInt32(db.MoveCategory(categoryId, newParentCategoryId));
                }
            }

            // only a returnValue of 1 indicates success
            return (returnValue == 1);
        }
Ejemplo n.º 4
0
 public static void UpdateCategoryName(int categoryId, string newName)
 {
     using (CategoriesDataAdapter db = new CategoriesDataAdapter())
     {
         db.UpdateCategoryName(categoryId, newName);
     }
 }
Ejemplo n.º 5
0
        public static bool RemoveCategory(int categoryId)
        {
            int result = 0;

            if (categoryId != DefaultValues.CategoryIdMinValue)
            {
                using (CategoriesDataAdapter db = new CategoriesDataAdapter())
                {
                    result = Convert.ToInt32(db.RemoveCategory(categoryId));
                }
            }

            return (result > 0);
        }
Ejemplo n.º 6
0
 public CategoriesDB()
 {
     _categories = new CategoriesDataAdapter();
 }