protected void Save() { var lastMailChimpId = MailChimpSettings.ApiKey; MailChimpSettings.FromName = txtFromName.Text; MailChimpSettings.FromEmail = txtFromEmail.Text; MailChimpSettings.ApiKey = txtMailChimpId.Text; if (string.IsNullOrEmpty(txtMailChimpId.Text)) { MailChimpService.UnsubscribeListMembers(MailChimpSettings.ApiKey, MailChimpSettings.RegUsersList); MailChimpService.UnsubscribeListMembers(MailChimpSettings.ApiKey, MailChimpSettings.OrderCustomersList); MailChimpSettings.RegUsersList = string.Empty; MailChimpSettings.OrderCustomersList = string.Empty; return; } var currentMailChimpId = MailChimpSettings.ApiKey; if (!ValidateData()) { lblMessage.Text = (string)GetLocalResourceObject("MailChimp_Error"); lblMessage.ForeColor = Color.Red; MailChimpSettings.ApiKey = lastMailChimpId; return; } if (!string.Equals(lastMailChimpId, currentMailChimpId)) { MailChimpSettings.RegUsersList = string.Empty; MailChimpSettings.OrderCustomersList = string.Empty; return; } if (ddlMailChimpLists.SelectedValue == "0") { MailChimpService.UnsubscribeListMembers(MailChimpSettings.ApiKey, MailChimpSettings.RegUsersList); } else { MailChimpService.SubscribeListMembers(MailChimpSettings.ApiKey, ddlMailChimpLists.SelectedValue, SubscriptionService.GetSubscribedEmails()); } if (ddlMailChimpOrderCustomer.SelectedValue == "0") { MailChimpService.UnsubscribeListMembers(MailChimpSettings.ApiKey, MailChimpSettings.OrderCustomersList); } else { MailChimpService.SubscribeListMembers(MailChimpSettings.ApiKey, ddlMailChimpOrderCustomer.SelectedValue, AdvantShop.Orders.OrderService.GetOrderCustomersEmails()); } MailChimpSettings.RegUsersList = ddlMailChimpLists.SelectedValue != "0" ? ddlMailChimpLists.SelectedValue : string.Empty; MailChimpSettings.OrderCustomersList = ddlMailChimpOrderCustomer.SelectedValue != "0" ? ddlMailChimpOrderCustomer.SelectedValue : string.Empty; LoadData(); lblMessage.Text = (string)GetLocalResourceObject("MailChimp_ChangesSaved"); lblMessage.ForeColor = Color.Blue; lblMessage.Visible = true; }