Пример #1
0
    public bool SaveData()
    {
        if (!ValidateData())
        {
            return(false);
        }

        SettingsMailChimp.MailChimpActive = ckbActive.Checked;
        if (SettingsMailChimp.MailChimpId != txtMailChimpId.Text)
        {
            SettingsMailChimp.MailChimpRegUsersList   = string.Empty;
            SettingsMailChimp.MailChimpUnRegUsersList = string.Empty;
            SettingsMailChimp.MailChimpId             = txtMailChimpId.Text;
        }
        else
        {
            if (!ckbActive.Checked)
            {
                return(true);
            }


            SettingsMailChimp.MailChimpId = txtMailChimpId.Text;
            //if (ddlMailChimpListsAll.SelectedValue == "0")
            //{
            //    MailChimp.UnsubscribeListMembers(SettingsMailChimp.MailChimpId, SettingsMailChimp.MailChimpAllUsersList);
            //}
            //else
            //{
            //    MailChimp.SubscribeListMember(SettingsMailChimp.MailChimpId, ddlMailChimpListsAll.SelectedValue,
            //                                 SubscribeService.SubscribeGetAllCustomerEmails());
            //}

            if (ddlMailChimpListsReg.SelectedValue == "0")
            {
                MailChimp.UnsubscribeListMembers(SettingsMailChimp.MailChimpId, SettingsMailChimp.MailChimpRegUsersList);
            }
            else
            {
                MailChimp.SubscribeListMember(SettingsMailChimp.MailChimpId, ddlMailChimpListsReg.SelectedValue,
                                              SubscribeService.SubscribeGetRegCustomerEmails());
            }

            if (ddlMailChimpListsUnReg.SelectedValue == "0")
            {
                MailChimp.UnsubscribeListMembers(SettingsMailChimp.MailChimpId,
                                                 SettingsMailChimp.MailChimpUnRegUsersList);
            }
            else
            {
                MailChimp.SubscribeListMember(SettingsMailChimp.MailChimpId, ddlMailChimpListsUnReg.SelectedValue,
                                              SubscribeService.SubscribeGetUnRegCustomerEmails());
            }

            SettingsMailChimp.MailChimpRegUsersList   = ddlMailChimpListsReg.SelectedValue;
            SettingsMailChimp.MailChimpUnRegUsersList = ddlMailChimpListsUnReg.SelectedValue;
            //SettingsMailChimp.MailChimpAllUsersList = ddlMailChimpListsAll.SelectedValue;
        }
        LoadData();
        return(true);
    }