예제 #1
0
        /// <summary>
        /// Gets the overview for a combobox
        /// </summary>
        public static List <CategoryItem> GetOverview(int?parentId = null, string prefix = "", int excludeId = 0, bool addSelect = true)
        {
            var result = new List <CategoryItem>();

            if (addSelect)
            {
                result.Add(new CategoryItem()
                {
                    ID = null, Name = "- Select -"
                });
            }


            List <Categories> _overview = DAL_Categories.GetAll(parentId, excludeId);

            foreach (var _item in _overview)
            {
                result.Add(new CategoryItem()
                {
                    ID   = _item.Id,
                    Name = ($"{prefix} {_item.Name}").Trim()
                });

                string prefixNext = prefix + "-";

                result.AddRange(GetOverview(_item.Id, prefixNext, excludeId, false));
            }

            return(result);
        }
예제 #2
0
 /// <summary>
 /// Get all the product categories in a list
 /// </summary>
 /// <returns>List of product categories</returns>
 public static List <Categories> GetAll()
 {
     try
     {
         return(DAL_Categories.GetAll());
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
 /// <summary>
 /// update the model
 /// </summary>
 private static void Update(Categories model)
 {
     try
     {
         DAL_Categories.Update(model);
     }
     catch (Exception)
     {
         throw;
     }
 }