public object GetAllCountries() { logger.Debug("Start"); List <Country> countries = new List <Country>(); try { countries = _ldapService.GetAllCountries(); } catch (Exception e) { logger.ErrorException("Exception", e); } return(countries); }
public void PopulateCountries() { IEnumerable <CountryViewModel> countries = AutoMapper.Mapper.Map <IEnumerable <CountryViewModel> >(_ldapService.GetAllCountries()); List <SelectListItem> countriesList = countries.Select(countryViewModel => new SelectListItem { Value = countryViewModel.Code, Text = countryViewModel.Name }).OrderBy(t => t.Text).ToList(); SelectList countriesSelectList = new SelectList(countriesList, "value", "text"); ViewData["countries"] = countriesSelectList; }