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

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