public static List <CATEGORIES_DTO> GetAllCategories() { using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities()) { var categoriesList = CategoryCRUD.GetAllCategories(ctx); List <CATEGORIES_DTO> categories = new List <CATEGORIES_DTO>(); foreach (var category in categoriesList) { categories.Add(CATEGORIES_Casting.CastToDTO(category)); } return(categories); } }
public static List <CATEGORIES_DTO> GetAllSubCategory(int id) { using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities()) { var categoriesList = CategoryCRUD.GetAllCategories(ctx); var subCategoryList = categoriesList.Where(u => u.parentCategory == id).ToList(); List <CATEGORIES_DTO> categories = new List <CATEGORIES_DTO>(); foreach (var category in subCategoryList) { categories.Add(CATEGORIES_Casting.CastToDTO(category)); } return(categories); } }
public static List <CategoryTreeItem> GetCategoryTree() { using (var ctx = new checkTestEntities1()) { var categoriesList = CategoryCRUD.GetAllCategories(ctx); List <CategoryTreeItem> categoryTreeList = new List <CategoryTreeItem>(); categoryTreeList.Add(new CategoryTreeItem() { id = 0, name = "all", children = new List <CategoryTreeItem>() }); GetAllCategortTree(categoriesList, null, categoryTreeList[0]); return(categoryTreeList); } }
/// <summary> ///פונקציה המחזירה עץ המורכב מכל הקטגוריות /// </summary> /// <returns></returns> public static List <CategoryTreeItem> GetCategoryTree() { using (var ctx = new testitprojectEntities()) { var categoriesList = CategoryCRUD.GetAllCategories(ctx); List <CategoryTreeItem> categoryTreeList = new List <CategoryTreeItem>(); categoryTreeList.Add(new CategoryTreeItem() { id = 0, name = "all", children = new List <CategoryTreeItem>() }); GetAllCategortTree(categoriesList, null, categoryTreeList[0]); if (categoryTreeList[0].children.Count > 0) { return(categoryTreeList[0].children); } return(new List <CategoryTreeItem>()); } }