internal static OwnerVm MapToOwnerVm(this Owner owner, OwnerType ownerType) { OwnerVm ownerVm = new OwnerVm() { Id = owner.Id, NewOwner = new NewOwnerVm() { Address = AdminViewModelsProvider.GetAddressVm(), PhoneList = AdminViewModelsProvider.GetPhoneList(ownerType), EmailList = AdminViewModelsProvider.GetEmailListVm(ownerType), Contacts = new List <ContactVm>() { AdminViewModelsProvider.GetContactVm(ownerType) }, LogoImages = new ImageListVm(ownerType.MapToDisplayName()), OwnerType = ownerType }, Owners = OwnerBc.Instance.GetAllByOwnerType(owner.OwnerType).Select <Owner, SelectListItem>((Owner m) => { SelectListItem selectListItem = new SelectListItem(); long?id = m.Id; selectListItem.set_Value(id.ToString()); selectListItem.set_Text(m.Name); id = ownerVm.Id; long?nullable = m.Id; selectListItem.set_Selected(id.GetValueOrDefault() == nullable.GetValueOrDefault() & id.HasValue == nullable.HasValue); return(selectListItem); }).ToList <SelectListItem>() }; return(ownerVm); }
public static List <SelectListItem> GetStatesForSeo(SearchType searchType, long?countryId) { return(LocationBc.Instance.GetStates(countryId, searchType).Select <MSLivingChoices.Entities.Admin.State, SelectListItem>((MSLivingChoices.Entities.Admin.State s) => { SelectListItem selectListItem = new SelectListItem(); selectListItem.set_Text(s.Name); selectListItem.set_Value(s.Id.ToString()); return selectListItem; }).ToList <SelectListItem>()); }
public static List <SelectListItem> GetCountriesForSeo() { return(LocationBc.Instance.GetUsableCountries().Select <MSLivingChoices.Entities.Admin.Country, SelectListItem>((MSLivingChoices.Entities.Admin.Country c) => { SelectListItem selectListItem = new SelectListItem(); selectListItem.set_Text(c.Name); selectListItem.set_Value(c.Id.ToString()); return selectListItem; }).ToList <SelectListItem>()); }
public static List <SelectListItem> CountryListToSelectListItems(IEnumerable <Country> countryList, string selectedCountryCode) { List <SelectListItem> result = new List <SelectListItem>(); foreach (Country country in countryList) { SelectListItem item = new SelectListItem(); item.set_Text(country.Name); item.set_Value(country.Code); item.set_Selected((selectedCountryCode == null ? false : country.Code == selectedCountryCode)); result.Add(item); } return(result); }
public static AddressVm Repopulate(this AddressVm address) { if (!address.Country.Id.HasValue) { address.Country.Id = LocationBc.Instance.DefaultCountry.Id; } List <Country> countries = LocationBc.Instance.GetAllCountries(); address.Country.AvailableCountries = countries.ConvertAll <SelectListItem>((Country m) => { SelectListItem selectListItem = new SelectListItem(); long?id = m.Id; selectListItem.set_Value(id.ToString()); selectListItem.set_Text(m.Name); id = m.Id; long?nullable = address.Country.Id; selectListItem.set_Selected(id.GetValueOrDefault() == nullable.GetValueOrDefault() & id.HasValue == nullable.HasValue); return(selectListItem); }); List <State> states = LocationBc.Instance.GetStates(address.Country.Id); address.State.AvailableStates = states.ConvertAll <SelectListItem>((State m) => { SelectListItem selectListItem = new SelectListItem(); long?id = m.Id; selectListItem.set_Value(id.ToString()); selectListItem.set_Text(m.Name); id = m.Id; long?nullable = address.State.Id; selectListItem.set_Selected(id.GetValueOrDefault() == nullable.GetValueOrDefault() & id.HasValue == nullable.HasValue); return(selectListItem); }); if (address.State.Id.HasValue) { List <City> cities = LocationBc.Instance.GetCities(address.State.Id); address.City.AvailableCities = cities.ConvertAll <SelectListItem>((City m) => { SelectListItem selectListItem = new SelectListItem(); long?id = m.Id; selectListItem.set_Value(id.ToString()); selectListItem.set_Text(m.Name); id = m.Id; long?nullable = address.City.Id; selectListItem.set_Selected(id.GetValueOrDefault() == nullable.GetValueOrDefault() & id.HasValue == nullable.HasValue); return(selectListItem); }); } else { address.City.AvailableCities = new List <SelectListItem>(); } return(address); }
public static List <SelectListItem> GetEditableCategories() { List <SelectListItem> selectListItems = new List <SelectListItem>(); SelectListItem selectListItem = new SelectListItem(); selectListItem.set_Text(AdditionalInfoClass.SeniorHousingAndCareCategoryService.GetEnumLocalizedValue <AdditionalInfoClass>() ?? AdditionalInfoClass.SeniorHousingAndCareCategoryService.ToString()); selectListItem.set_Value(10.ToString()); selectListItems.Add(selectListItem); SelectListItem selectListItem1 = new SelectListItem(); selectListItem1.set_Text(AdditionalInfoClass.SeniorHousingAndCareCategory.GetEnumLocalizedValue <AdditionalInfoClass>() ?? AdditionalInfoClass.SeniorHousingAndCareCategory.ToString()); selectListItem1.set_Value(2.ToString()); selectListItems.Add(selectListItem1); return(selectListItems); }
public static List <SelectListItem> EnumToSelectListItems <T>(Nullable <T> selectedItem = null) where T : struct { if (!typeof(T).IsEnum) { throw new ArgumentException(ErrorMessages.NotEnumType); } return(ConverterHelpers.EnumToList <T>().Select <T, SelectListItem>((T enumItem) => { string text = enumItem.ToString(); SelectListItem selectListItem = new SelectListItem(); selectListItem.set_Text(enumItem.GetEnumLocalizedValue <T>() ?? text); selectListItem.set_Value(text); selectListItem.set_Selected((!selectedItem.HasValue ? false : enumItem.Equals(selectedItem.Value))); return selectListItem; }).ToList <SelectListItem>()); }
public static List <SelectListItem> EnumToKoSelectListItems <T>(T selectedValue) where T : struct { if (!typeof(T).IsEnum) { throw new ArgumentException(ErrorMessages.NotEnumType); } return(ConverterHelpers.EnumToList <T>().Select <T, SelectListItem>((T enumItem) => { string text = enumItem.ToString(); string value = ((int)(object)enumItem).ToString(); SelectListItem selectListItem = new SelectListItem(); selectListItem.set_Text(enumItem.GetEnumLocalizedValue <T>() ?? text); selectListItem.set_Value(value); return selectListItem; }).ToList <SelectListItem>()); }
public static ListingDetailsVm Repopulate(this ListingDetailsVm viewModel) { viewModel.PropertyManager.Owners = OwnerBc.Instance.GetAllByOwnerType(OwnerType.PropertyManager).Select <Owner, SelectListItem>((Owner m) => { SelectListItem selectListItem = new SelectListItem(); selectListItem.set_Value(m.Id.ToString()); selectListItem.set_Text(m.Name); return(selectListItem); }).ToList <SelectListItem>(); viewModel.Builder.Owners = OwnerBc.Instance.GetAllByOwnerType(OwnerType.Builder).Select <Owner, SelectListItem>((Owner m) => { SelectListItem selectListItem = new SelectListItem(); selectListItem.set_Value(m.Id.ToString()); selectListItem.set_Text(m.Name); return(selectListItem); }).ToList <SelectListItem>(); viewModel.PropertyManager.NewOwner = viewModel.PropertyManager.NewOwner.Repopulate(); viewModel.Builder.NewOwner = viewModel.Builder.NewOwner.Repopulate(); return(viewModel); }
public static OwnerVm GetOwnerVm(OwnerType ownerType) { return(new OwnerVm() { NewOwner = new NewOwnerVm() { Address = AdminViewModelsProvider.GetAddressVm(), PhoneList = AdminViewModelsProvider.GetPhoneList(ownerType), EmailList = AdminViewModelsProvider.GetEmailListVm(ownerType), Contacts = new List <ContactVm>() { AdminViewModelsProvider.GetContactVm(ownerType) }, LogoImages = new ImageListVm(ownerType.MapToDisplayName()), OwnerType = ownerType }, Owners = OwnerBc.Instance.GetAllByOwnerType(ownerType).Select <Owner, SelectListItem>((Owner m) => { SelectListItem selectListItem = new SelectListItem(); selectListItem.set_Value(m.Id.ToString()); selectListItem.set_Text(m.Name); return selectListItem; }).ToList <SelectListItem>() }); }
public async Task <ActionResult> SendCode(string returnUrl, bool rememberMe) { string userId = await this.SignInManager.GetVerifiedUserIdAsync(); if (userId == null) { return((ActionResult)this.View("Error")); } IList <string> userFactors = await((Microsoft.AspNet.Identity.UserManager <ApplicationUser, string>) this.UserManager).GetValidTwoFactorProvidersAsync(userId); List <SelectListItem> factorOptions = userFactors.Select <string, SelectListItem>((Func <string, SelectListItem>)(purpose => { SelectListItem selectListItem = new SelectListItem(); selectListItem.set_Text(purpose); selectListItem.set_Value(purpose); return(selectListItem); })).ToList <SelectListItem>(); return((ActionResult)this.View((object)new SendCodeViewModel() { Providers = (ICollection <SelectListItem>)factorOptions, ReturnUrl = returnUrl, RememberMe = rememberMe })); }