public ModelCategory Find(int nID) { if (AllCategories == null) { return(null); } return(AllCategories.Find(m => m.Id == nID)); }
public ModelCategory Find(string sCode) { if (AllCategories == null) { return(null); } return(AllCategories.Find(m => string.Equals(sCode, m.Code))); }
private static List <string> takeCategories(StreamReader file) { string categoryHeader = file.ReadLine()?.Substring(9) ?? ""; List <string> result = categoryHeader.Split(" ").ToList(); foreach (string category in result) { if (AllCategories.Find(cat => cat == category) == null) { AllCategories.Add(category); } } return(result); }
internal List <ModelCategory> GetAllChildCategories(int nCategoryID) { List <ModelCategory> aryResult = new List <ModelCategory>(); ModelCategory category = AllCategories.Find(m => m.Id == nCategoryID); if (category != null) { aryResult.Add(category); List <ModelCategory> childCategories = AllCategories.FindAll(m => m.ParentId == nCategoryID); foreach (ModelCategory childCategory in childCategories) { List <ModelCategory> aryChildCategory = GetAllChildCategories(childCategory.Id); aryResult.AddRange(aryChildCategory); } } return(aryResult); }