예제 #1
0
        protected void LoadData()
        {
            txtUniSenderId.Text = UniSenderSettings.ApiKey;
            txtFromName.Text    = UniSenderSettings.FromName;
            txtFromEmail.Text   = UniSenderSettings.FromEmail;

            var lists = UniSenderService.GetLists();

            if (lists != null && lists.Count > 0)
            {
                ddlUniSenderListsReg.DataSource = lists;
                ddlUniSenderListsReg.DataBind();
                if (lists.All(item => item.id != UniSenderSettings.RegUsersList))
                {
                    UniSenderSettings.RegUsersList = string.Empty;
                }
                ddlUniSenderListsReg.SelectedValue = string.IsNullOrEmpty(UniSenderSettings.RegUsersList)
                    ? "0"
                    : UniSenderSettings.RegUsersList;

                ddlUniSenderListsOrderCustomers.DataSource = lists;
                ddlUniSenderListsOrderCustomers.DataBind();
                if (lists.All(item => item.id != UniSenderSettings.OrderCustomersList))
                {
                    UniSenderSettings.OrderCustomersList = string.Empty;
                }
                ddlUniSenderListsOrderCustomers.SelectedValue = string.IsNullOrEmpty(UniSenderSettings.OrderCustomersList)
                    ? "0"
                    : UniSenderSettings.OrderCustomersList;
            }
            else
            {
                ddlUniSenderListsReg.Items.Clear();
                ddlUniSenderListsReg.Items.Add(new ListItem
                {
                    Text  = CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ru" ? "Нет привязки к списку" : "No binding to the list",
                    Value = @"0"
                });
                ddlUniSenderListsReg.DataBind();

                ddlUniSenderListsOrderCustomers.Items.Clear();
                ddlUniSenderListsOrderCustomers.Items.Add(new ListItem
                {
                    Text  = CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ru" ? "Нет привязки к списку" : "No binding to the list",
                    Value = @"0"
                });
                ddlUniSenderListsOrderCustomers.DataBind();
            }
        }
예제 #2
0
        protected void Save()
        {
            var lastUniSenderId = UniSenderSettings.ApiKey;

            UniSenderSettings.FromName  = txtFromName.Text;
            UniSenderSettings.FromEmail = txtFromEmail.Text;
            UniSenderSettings.ApiKey    = txtUniSenderId.Text;

            if (string.IsNullOrEmpty(txtUniSenderId.Text))
            {
                UniSenderService.UnsubscribeListMembers(UniSenderSettings.RegUsersList);
                UniSenderService.UnsubscribeListMembers(UniSenderSettings.OrderCustomersList);
                return;
            }

            var currentUnisenderId = UniSenderSettings.ApiKey;

            if (!ValidateData())
            {
                lblMessage.Text      = (string)GetLocalResourceObject("UniSender_Error");
                lblMessage.ForeColor = Color.Red;

                UniSenderSettings.ApiKey = lastUniSenderId;
                return;
            }

            if (!string.Equals(lastUniSenderId, currentUnisenderId))
            {
                UniSenderSettings.RegUsersList       = string.Empty;
                UniSenderSettings.OrderCustomersList = string.Empty;
                return;
            }

            if (ddlUniSenderListsReg.SelectedValue == "0")
            {
                UniSenderService.UnsubscribeListMembers(UniSenderSettings.RegUsersList);
            }
            else
            {
                UniSenderService.SubscribeListMembers(ddlUniSenderListsReg.SelectedValue,
                                                      SubscriptionService.GetSubscribedEmails());
            }

            if (ddlUniSenderListsOrderCustomers.SelectedValue == "0")
            {
                UniSenderService.UnsubscribeListMembers(UniSenderSettings.OrderCustomersList);
            }
            else
            {
                UniSenderService.SubscribeListMembers(ddlUniSenderListsOrderCustomers.SelectedValue,
                                                      AdvantShop.Orders.OrderService.GetOrderCustomersEmails());
            }

            UniSenderSettings.RegUsersList = ddlUniSenderListsReg.SelectedValue != "0"
                ? ddlUniSenderListsReg.SelectedValue : string.Empty;
            UniSenderSettings.OrderCustomersList = ddlUniSenderListsOrderCustomers.SelectedValue != "0"
                ? ddlUniSenderListsOrderCustomers.SelectedValue : string.Empty;

            LoadData();
            lblMessage.Text      = (string)GetLocalResourceObject("UniSender_ChangesSaved");
            lblMessage.ForeColor = Color.Blue;
            lblMessage.Visible   = true;
        }