Esempio n. 1
0
 public ModelCategory Find(int nID)
 {
     if (AllCategories == null)
     {
         return(null);
     }
     return(AllCategories.Find(m => m.Id == nID));
 }
Esempio n. 2
0
 public ModelCategory Find(string sCode)
 {
     if (AllCategories == null)
     {
         return(null);
     }
     return(AllCategories.Find(m => string.Equals(sCode, m.Code)));
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }