protected void Page_Load(object sender, EventArgs e) { FillCountryRegionOptionsHtml(); if (!IsPostBack) { LoadShippingTransactions(); int?deleteRateId = WA.Parser.ToInt(Request.QueryString["deleteRate"]); if (deleteRateId.HasValue) { ShippingServiceRate toDelete = new ShippingServiceRate(); if (toDelete.LoadByPrimaryKey(deleteRateId.Value)) { toDelete.MarkAsDeleted(); toDelete.Save(); } } short?deleteId = WA.Parser.ToShort(Request.QueryString["delete"]); if (deleteId.HasValue) { DataModel.ShippingServiceRateType toDelete = new DataModel.ShippingServiceRateType(); if (toDelete.LoadByPrimaryKey(deleteId.Value)) { toDelete.MarkAsDeleted(); toDelete.Save(); } } chkShippingTablesEnabled.Checked = shippingTablesService.IsEnabled; // FEDEX chkFedExEnabled.Checked = fedExService.IsEnabled; Dictionary <string, string> fedexSettings = fedExService.GetSettingsDictionary(); txtFedExAccountNum.Text = fedexSettings.TryGetValueOrEmpty("accountNumber"); txtFedExMeterNum.Text = fedexSettings.TryGetValueOrEmpty("meterNumber"); txtFedExSmartPostHub.Text = fedexSettings.TryGetValueOrEmpty("smartPostHubId"); txtFedExApiKey.Text = fedexSettings.TryGetValueOrEmpty("apiKey"); txtFedExApiPassword.Text = fedexSettings.TryGetValueOrEmpty("apiPassword"); chkFedExIsTestGateway.Checked = WA.Parser.ToBool(fedexSettings.TryGetValueOrEmpty("isTestGateway")).GetValueOrDefault(false); ddlLabelStockType.SelectedValue = fedexSettings.TryGetValueOrDefault("labelStockType", "0"); // UPS chkUpsEnabled.Checked = upsService.IsEnabled; Dictionary <string, string> upsSettings = upsService.GetSettingsDictionary(); txtUpsUserId.Text = upsSettings.TryGetValueOrEmpty("userId"); txtUpsPassword.Text = upsSettings.TryGetValueOrEmpty("password"); txtUpsAccountNumber.Text = upsSettings.TryGetValueOrEmpty("accountNumber"); txtUpsAccessKey.Text = upsSettings.TryGetValueOrEmpty("accessKey"); chkUpsIsTestGateway.Checked = WA.Parser.ToBool(upsSettings.TryGetValueOrEmpty("isTestGateway")).GetValueOrDefault(false); LoadShippingRates(); } }
protected void btnSave_Click(object sender, EventArgs e) { StoreContext.CurrentStore.UpdateSetting(StoreSettingNames.ShipmentPackagingStrategy, ddlShipmentPackaging.SelectedValue); //--- Custom Shipping Dictionary <string, string> settings = shippingTablesService.GetSettingsDictionary(); settings["IsEnabled"] = chkShippingTablesEnabled.Checked.ToString(); shippingTablesService.UpdateSettingsDictionary(settings); SaveShippingRows(); //--- FedEx settings = fedExService.GetSettingsDictionary(); settings["IsEnabled"] = chkFedExEnabled.Checked.ToString(); settings["accountNumber"] = txtFedExAccountNum.Text; settings["meterNumber"] = txtFedExMeterNum.Text; settings["smartPostHubId"] = txtFedExSmartPostHub.Text; settings["apiKey"] = txtFedExApiKey.Text; settings["apiPassword"] = txtFedExApiPassword.Text; settings["isTestGateway"] = chkFedExIsTestGateway.Checked.ToString(); settings["labelStockType"] = ddlLabelStockType.SelectedValue; fedExService.UpdateSettingsDictionary(settings); // UPS settings = upsService.GetSettingsDictionary(); settings["IsEnabled"] = chkUpsEnabled.Checked.ToString(); settings["userId"] = txtUpsUserId.Text; settings["password"] = txtUpsPassword.Text; settings["accountNumber"] = txtUpsAccountNumber.Text; settings["accessKey"] = txtUpsAccessKey.Text; settings["isTestGateway"] = chkUpsIsTestGateway.Checked.ToString(); upsService.UpdateSettingsDictionary(settings); Response.Redirect(StoreUrls.AdminWithFlash(ModuleDefs.Admin.Views.Shipping, "Shipping options saved")); }
private void Init(int storeId, ShippingProviderType providerType) { this.storeId = storeId; this.providerType = providerType; dbShippingService = DataModel.ShippingService.Find(storeId, providerType); if (dbShippingService == null) { throw new ApplicationException(string.Format("Unable to find ShippingService for ProviderType '{0}'", providerType)); } this.config = dbShippingService.GetSettingsDictionary(); }