public async Task <IActionResult> GetStatesJson( string countryCode) { var country = await dataManager.FetchCountry(countryCode); List <IGeoZone> states; if (country != null) { states = await dataManager.GetGeoZonesByCountry(country.Id); } else { states = new List <IGeoZone>(); //empty list } var selecteList = new SelectList(states, "Code", "Name"); return(Json(selecteList)); }
public async Task <IActionResult> CompanyInfo( Guid?siteGuid, int slp = 1) { ISiteSettings selectedSite; // only server admin site can edit other sites settings if ((siteGuid.HasValue) && (siteGuid.Value != Guid.Empty) && (siteGuid.Value != siteManager.CurrentSite.SiteGuid) && (siteManager.CurrentSite.IsServerAdminSite)) { selectedSite = await siteManager.Fetch(siteGuid.Value); ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Company Info", selectedSite.SiteName); } else { selectedSite = siteManager.CurrentSite; ViewData["Title"] = "Company Info"; } CompanyInfoViewModel model = new CompanyInfoViewModel(); model.SiteGuid = selectedSite.SiteGuid; model.SiteId = selectedSite.SiteId; model.CompanyName = selectedSite.CompanyName; model.CompanyStreetAddress = selectedSite.CompanyStreetAddress; model.CompanyStreetAddress2 = selectedSite.CompanyStreetAddress2; model.CompanyLocality = selectedSite.CompanyLocality; model.CompanyRegion = selectedSite.CompanyRegion; model.CompanyPostalCode = selectedSite.CompanyPostalCode; model.CompanyCountry = selectedSite.CompanyCountry; model.CompanyPhone = selectedSite.CompanyPhone; model.CompanyFax = selectedSite.CompanyFax; model.CompanyPublicEmail = selectedSite.CompanyPublicEmail; model.AvailableCountries.Add(new SelectListItem { Text = "-Please select-", Value = "Selects items" }); var countries = await geoDataManager.GetAllCountries(); Guid selectedCountryGuid = Guid.Empty; foreach (var country in countries) { if (country.ISOCode2 == model.CompanyCountry) { selectedCountryGuid = country.Guid; } model.AvailableCountries.Add(new SelectListItem() { Text = country.Name, Value = country.ISOCode2.ToString() }); } if (selectedCountryGuid != Guid.Empty) { var states = await geoDataManager.GetGeoZonesByCountry(selectedCountryGuid); foreach (var state in states) { model.AvailableStates.Add(new SelectListItem() { Text = state.Name, Value = state.Code }); } } return(View(model)); }