private void AttachOptionRow(ShippingMethodDto.ShippingOptionParameterRow row) { if (row.RowState == DataRowState.Detached) { _shippingMethodDto.ShippingOptionParameter.Rows.Add(row); } }
private ShippingMethodDto.ShippingOptionParameterRow GetOrCreateParameterRow(string parameterName) { ShippingMethodDto.ShippingOptionParameterRow row = GetParameterRow(parameterName); if (row == null) { row = _shippingMethodDto.ShippingOptionParameter.NewShippingOptionParameterRow(); row.ShippingOptionId = _shippingMethodDto.ShippingOption[0].ShippingOptionId; row.Parameter = parameterName; } return(row); }
public void LoadObject(object dto) { _shippingMethodDto = dto as ShippingMethodDto; if (!Page.IsPostBack) { BindCountryList(); } if (_shippingMethodDto != null && _shippingMethodDto.ShippingOptionParameter.Rows.Count > 0) { ShippingMethodDto.ShippingOptionParameterRow apiUrlRow = GetParameterRow("ApiUrl"); ShippingMethodDto.ShippingOptionParameterRow publicIdRow = GetParameterRow("PublicId"); ShippingMethodDto.ShippingOptionParameterRow postalCodeFromRow = GetParameterRow("PostalCodeFrom"); ShippingMethodDto.ShippingOptionParameterRow countryFromRow = GetParameterRow("CountryFrom"); if (apiUrlRow != null) { txtApiUrl.Text = apiUrlRow.Value; } else { txtApiUrl.Text = "http://fraktguide.bring.no/fraktguide/products/"; } if (publicIdRow != null) { txtPublicId.Text = publicIdRow.Value; } if (postalCodeFromRow != null) { txtPostalCodeFrom.Text = postalCodeFromRow.Value; } if (countryFromRow != null) { ddlCountryFrom.SelectedValue = countryFromRow.Value; } } }
public void SaveChanges(object dto) { _shippingMethodDto = dto as ShippingMethodDto; if (_shippingMethodDto != null && _shippingMethodDto.ShippingOptionParameter != null) { ShippingMethodDto.ShippingOptionParameterRow apiUrlRow = GetOrCreateParameterRow("ApiUrl"); ShippingMethodDto.ShippingOptionParameterRow publicIdRow = GetOrCreateParameterRow("PublicId"); ShippingMethodDto.ShippingOptionParameterRow postalCodeFromRow = GetOrCreateParameterRow("PostalCodeFrom"); ShippingMethodDto.ShippingOptionParameterRow countryFromRow = GetOrCreateParameterRow("CountryFrom"); apiUrlRow.Value = txtApiUrl.Text; publicIdRow.Value = txtPublicId.Text; postalCodeFromRow.Value = txtPostalCodeFrom.Text; countryFromRow.Value = ddlCountryFrom.SelectedValue; AttachOptionRow(apiUrlRow); AttachOptionRow(publicIdRow); AttachOptionRow(postalCodeFromRow); AttachOptionRow(countryFromRow); } }