Пример #1
0
        public static IEnumerable <SelectListItem> GetAllDestinations(IDestinationService destinationsService)
        {
            var destinations = destinationsService.GetAllDestinationsAsync();
            var groups       = new List <SelectListGroup>();

            foreach (var destinationViewModel in destinations)
            {
                if (groups.All(g => g.Name != destinationViewModel.Name))
                {
                    groups.Add(new SelectListGroup {
                        Name = destinationViewModel.Name
                    });
                }
            }

            return(destinations.Select(x => new SelectListItem
            {
                Value = x.Id.ToString(),
                Text = x.Name,
            }));
        }