Beispiel #1
0
        public async Task <List <SelectListItem> > ServiceIconSelectList(SelectListFirstItemEnum firstItem = SelectListFirstItemEnum.None, CancellationToken cancellationToken = default(CancellationToken))
        {
            List <SelectListItem> listItems    = new List <SelectListItem>();
            List <ServiceIcon>    serviceIcons = (await _uow.ServiceIconRepository.GetAllAsync()).ToList();

            listItems.AddRange(serviceIcons.Select(item => new SelectListItem
            {
                Text  = item.ServiceIconName,
                Value = item.ServiceIconId.ToString()
            }).ToList <SelectListItem>());

            AddFirstItem(listItems, firstItem);

            return(listItems);
        }
Beispiel #2
0
        private void AddFirstItem(List <SelectListItem> lst, SelectListFirstItemEnum firstItem = SelectListFirstItemEnum.None)
        {
            switch (firstItem)
            {
            case SelectListFirstItemEnum.Select:
                AddSelectItem(lst);
                break;

            case SelectListFirstItemEnum.All:
                AddAllItem(lst);
                break;

            default:
                return;
            }
        }