Пример #1
0
        public static List <SelectListItem> GetParentCategories(int?selected, ILookupRepository rep)
        {
            var categoryList = new List <SelectListItem>();
            var categories   = rep.FetchParentCategories().Select(c_ => new Category(c_)).ToList();

            categories.ForEach(c => categoryList.Add(new SelectListItem
            {
                Text     = c.CategoryName,
                Value    = c.CategoryId.ToString(),
                Selected = selected.HasValue && (c.CategoryId == selected.Value)
            }));
            return(categoryList);
        }