protected void Process_AddEdit() { WarehouseData wareHouse = null; m_refWarehouse = new WarehouseApi(); if (this.m_iID > 0) { wareHouse = m_refWarehouse.GetItem(this.m_iID); } RegionData rData; rData = new RegionData(); rData = m_refRegion.GetItem(Convert.ToInt64(drp_address_region.SelectedValue)); CountryData cData; cData = new CountryData(); cData = m_refCountry.GetItem(System.Convert.ToInt32(drp_address_country.SelectedValue)); if (this.m_iID == 0) { wareHouse = new WarehouseData(txt_address_name.Text, new AddressData()); } wareHouse.Name = (string)txt_address_name.Text; if (this.m_iID > 0) { wareHouse.Id = Convert.ToInt64(lbl_address_id.Text); } wareHouse.Address.AddressLine1 = (string)txt_address_line1.Text; wareHouse.Address.AddressLine2 = (string)txt_address_line2.Text; wareHouse.Address.City = (string)txt_address_city.Text; if (wareHouse.Address.Region == null) { wareHouse.Address.Region = new RegionData(); } wareHouse.Address.Region.Id = Convert.ToInt64(drp_address_region.SelectedValue); wareHouse.Address.PostalCode = (string)txt_address_postal.Text; if (wareHouse.Address.Country == null) { wareHouse.Address.Country = new CountryData(); } wareHouse.Address.Country.Id = System.Convert.ToInt32(drp_address_country.SelectedValue); wareHouse.IsDefaultWarehouse = System.Convert.ToBoolean(chk_default_warehouse.Checked); if (this.m_iID > 0) { m_refWarehouse.Update(wareHouse); Response.Redirect(m_sPageName + "?action=view&id=" + this.m_iID.ToString(), false); } else { m_refWarehouse.Add(wareHouse); Response.Redirect(m_sPageName, false); } }