protected void BtnCreate_Click(object sender, EventArgs e) { if (Page.IsValid) { Country country; if (!string.IsNullOrEmpty(TxtName.Text)) { country = new Country(StoreId, TxtName.Text, long.Parse(DrpCurrencies.SelectedValue)); country.Save(); } else { DefaultCountry defaultCountry = CountryService.Instance.GetDefaultCountries().First(c => c.Code == DrpCountries.SelectedValue); country = new Country(StoreId, defaultCountry.Name, long.Parse(DrpCurrencies.SelectedValue)) { RegionCode = defaultCountry.Code }; country.Save(); foreach (Region region in defaultCountry.Regions) { CountryRegion countryRegion = new CountryRegion(StoreId, region.Name, country.Id) { RegionCode = region.Code }; countryRegion.Save(); } } } }
protected void BtnCreate_Click(object sender, EventArgs e) { if (Page.IsValid) { List <Country> countries = CountryService.Instance.GetAll(StoreId).ToList(); foreach (DefaultCountry defaultCountry in CountryService.Instance.GetDefaultCountries()) { if (!countries.Any(c => c.RegionCode == defaultCountry.Code || c.Name == defaultCountry.Name)) { Country country = new Country(StoreId, defaultCountry.Name, long.Parse(DrpCurrencies.SelectedValue)) { RegionCode = defaultCountry.Code }; country.Save(); foreach (Region region in defaultCountry.Regions) { CountryRegion countryRegion = new CountryRegion(StoreId, region.Name, country.Id) { RegionCode = region.Code }; countryRegion.Save(); } } } CreateControls.Visible = false; CreateAllCompleted.Visible = true; } }
protected void BtnCreate_Click( object sender, EventArgs e ) { if ( Page.IsValid ) { CountryRegion countryRegion = new CountryRegion( StoreId, TxtName.Text, _countryId ); countryRegion.Save(); Redirect( WebUtils.GetPageUrl( Constants.Pages.EditCountryRegion ) + "?id=" + countryRegion.Id + "&storeId=" + countryRegion.StoreId ); } }
protected void BtnCreate_Click(object sender, EventArgs e) { if (Page.IsValid) { CountryRegion countryRegion = new CountryRegion(StoreId, TxtName.Text, _countryId); countryRegion.Save(); Redirect(WebUtils.GetPageUrl(Constants.Pages.EditCountryRegion) + "?id=" + countryRegion.Id + "&storeId=" + countryRegion.StoreId); } }
protected void SaveButton_Clicked(object sender, EventArgs e) { if (Page.IsValid) { countryRegion.Name = TxtName.Text; countryRegion.RegionCode = TxtRegionCode.Text; countryRegion.DefaultShippingMethodId = DrpShippingMethods.SelectedValue.TryParse <long>(); countryRegion.DefaultPaymentMethodId = DrpPaymentMethods.SelectedValue.TryParse <long>(); countryRegion.Save(); ClientTools.ShowSpeechBubble(SpeechBubbleIcon.Save, CommonTerms.CountryRegionSaved, string.Empty); } }