public static CategoriesDataComponent.CategoriesDataTable GetParentCategoriesById(int categoryId) { using (CategoriesDataAdapter db = new CategoriesDataAdapter()) { return db.GetParentCategoriesById(categoryId); } }
/// <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); } }
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); }
public static void UpdateCategoryName(int categoryId, string newName) { using (CategoriesDataAdapter db = new CategoriesDataAdapter()) { db.UpdateCategoryName(categoryId, newName); } }
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); }
public CategoriesDB() { _categories = new CategoriesDataAdapter(); }