Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            StoreController storeController = new StoreController();
            bool newStore = false;

            if (storeInfo == null)
            {
                storeInfo = new StoreInfo();
                newStore = true;
            }

            storeInfo.PortalID = PortalId;
            storeInfo.Name = txtStoreName.Text;
            storeInfo.Description = txtDescription.Text;
            storeInfo.Keywords = txtKeywords.Text;
            storeInfo.DefaultEmailAddress = txtEmail.Text;
            storeInfo.CurrencySymbol = txtCurrencySymbol.Text;
            storeInfo.PortalTemplates = chkUsePortalTemplates.Checked;
            storeInfo.GatewayName = lstGateway.SelectedItem.Text;
            storeInfo.ShoppingCartPageID = int.Parse(lstShoppingCartPageID.SelectedValue);
            storeInfo.StorePageID = int.Parse(lstStorePageID.SelectedValue);
            storeInfo.AuthorizeCancel = chkAuthorizeCancel.Checked;

            if ((gatewayControl != null) && (gatewayControl.DataSource != null))
            {
                storeInfo.GatewaySettings = gatewayControl.DataSource.ToString();
            }

            if (chkUsePortalTemplates.Checked)
            {
                string hostFolder = MapPath(ModulePath);
                string portalFolder = PortalSettings.HomeDirectoryMapPath + "Store\\";
                string[] fileList = null;

                // Templates
                if (!Directory.Exists(portalFolder + "Templates"))
                {
                    Directory.CreateDirectory(portalFolder + "Templates");

                    fileList = Directory.GetFiles(hostFolder + "Templates", "*.*");

                    foreach (string file in fileList)
                    {
                        FileInfo fileInfo = new FileInfo(file);
                        fileInfo.CopyTo(portalFolder + "Templates\\" + fileInfo.Name, false);
                    }
                }

                // Images
                if (!Directory.Exists(portalFolder + "Templates\\Images"))
                {
                    Directory.CreateDirectory(portalFolder + "Templates\\Images");

                    fileList = Directory.GetFiles(hostFolder + "Templates\\Images", "*.*");

                    foreach (string file in fileList)
                    {
                        FileInfo fileInfo = new FileInfo(file);
                        fileInfo.CopyTo(portalFolder + "Templates\\Images\\" + fileInfo.Name, false);
                    }
                }

                // StyleSheet
                if (!Directory.Exists(portalFolder + "Templates\\StyleSheet"))
                {
                    Directory.CreateDirectory(portalFolder + "Templates\\StyleSheet");

                    fileList = Directory.GetFiles(hostFolder + "Templates\\StyleSheet", "*.*");

                    foreach (string file in fileList)
                    {
                        FileInfo fileInfo = new FileInfo(file);
                        fileInfo.CopyTo(portalFolder + "Templates\\StyleSheet\\" + fileInfo.Name, false);
                    }
                }

            }

            if (newStore)
            {
                storeInfo.CreatedByUser = UserInfo.Username;
                storeController.AddStoreInfo(storeInfo);
            }
            else
            {
                storeController.UpdateStoreInfo(storeInfo);
            }
        }
Exemplo n.º 2
0
 public void SetSettings(int portalID, string gatewaySettings)
 {
     StoreController controller = new StoreController();
     StoreInfo storeInfo = controller.GetStoreInfo(portalID);
     if (storeInfo != null)
     {
         storeInfo.GatewaySettings = gatewaySettings;
         controller.UpdateStoreInfo(storeInfo);
     }
 }