public ActionResult Subscribe(MailingListSubscribeViewModel viewModel)
        {
            //TODO: Remove this as it is for fake processing to check that only ".com" addresses are valid
            if (!ModelState.IsValid)
            {
                //TODO: move to base class and need to pull in my tempdata cookieprovider so we are multi-server tolerant with tempdata
                TempData["ViewData"] = ViewData;
                return(RedirectToAction("Subscribe"));
            }

            //TODO: do actual subscription processing

            string mailChimpApiKey = ConfigurationSettings.AppSettings["MailChimpApiKey"];
            string mailChimpListId = ConfigurationSettings.AppSettings["MailChimpListId"];

            var mailChimp = new MCApi(mailChimpApiKey, true);

            mailChimp.ListSubscribe(mailChimpListId, viewModel.EmailAddress,
                                    new List.Merges {
                { "FNAME", viewModel.FirstName },
                { "LNAME", viewModel.LastName }
            }, new List.SubscribeOptions()
            {
                DoubleOptIn    = false,
                SendWelcome    = false,
                UpdateExisting = true
            });

            //TODO: move to base class and need to pull in my tempdata cookieprovider so we are multi-server tolerant with tempdata
            TempData["alert-success"] = "Thank you! You are now signed up.";
            return(RedirectToAction("Subscribe"));
        }
Ejemplo n.º 2
0
        public ActionResult Subscribe(MailingListSubscribeViewModel viewModel)
        {
            //TODO: Remove this as it is for fake processing to check that only ".com" addresses are valid
            if (!ModelState.IsValid) {
                //TODO: move to base class and need to pull in my tempdata cookieprovider so we are multi-server tolerant with tempdata
                TempData["ViewData"] = ViewData;
                return RedirectToAction("Subscribe");
            }

            //TODO: do actual subscription processing

            string mailChimpApiKey = ConfigurationSettings.AppSettings["MailChimpApiKey"];
            string mailChimpListId = ConfigurationSettings.AppSettings["MailChimpListId"];

            var mailChimp = new MCApi(mailChimpApiKey, true);

            mailChimp.ListSubscribe(mailChimpListId, viewModel.EmailAddress,
                                    new List.Merges {
                                        {"FNAME", viewModel.FirstName},
                                        {"LNAME", viewModel.LastName}
                                    }, new List.SubscribeOptions() {
                                        DoubleOptIn = false,
                                        SendWelcome = false,
                                        UpdateExisting = true
                                    });

            //TODO: move to base class and need to pull in my tempdata cookieprovider so we are multi-server tolerant with tempdata
            TempData["alert-success"] = "Thank you! You are now signed up.";
            return RedirectToAction("Subscribe");
        }
        //Footer Signup 
        public bool Subscribe_SingleSignUp(string EmailAddress)
        {
            bool status = true;

            try
            {
                var mcApi = new MCApi(apiKey, false);

                List<List.Merges> SubscriptionInfo = new List<List.Merges>();

                var SubscriptionOptions = new MailChimp.Types.List.SubscribeOptions();
                SubscriptionOptions.DoubleOptIn = false;
                SubscriptionOptions.ReplaceInterests = false;
                SubscriptionOptions.EmailType = List.EmailType.Html;
                SubscriptionOptions.SendWelcome = false;
                SubscriptionOptions.UpdateExisting = true;

                var merges = GetListOfMerges_SingleSignUp(EmailAddress);

                var returnvalue = mcApi.ListSubscribe(MANvFATOfficialMembers_ListId, EmailAddress, merges, SubscriptionOptions);
            }
            catch (Exception ex)
            {
                if (IgnoreMailchimpErrors(ex.Message))
                { }
                else
                {
                    ErrorHandling.HandleException(ex);
                    status = false;
                }
            }

            return status;
        }
 public bool AddOrUpdateSubscriber(string email, string list, string apiKey)
 {
     var mcApi = new MCApi(apiKey, true);
     var merges = new List.Merges();
     var subscriptionOptions = new List.SubscribeOptions();
     subscriptionOptions.UpdateExisting = true;
     subscriptionOptions.DoubleOptIn = false;
     subscriptionOptions.SendWelcome = false;
     return mcApi.ListSubscribe(list, email, merges, subscriptionOptions);
 }
Ejemplo n.º 5
0
        public static void AccedeApi(string nombre, string apPaterno, string correo)
        {
            const string apiKey  = "eef4bc1722806a84538bc67d058b44c0-us7"; // Replace it before
            string       listId  = "c9ad222383";                           // Replace it before
            string       listId1 = "e321ec7f9d";

            var options = new List.SubscribeOptions
            {
                DoubleOptIn = true, EmailType = List.EmailType.Html, SendWelcome = false
            };

            //var entry = new Dictionary<string, object>();
            //entry.Add("FNAME", "Sergio");
            //entry.Add("LNAME", "Alvarez");

            //var lsi =  new listSubscribe(apiKey, listId, "*****@*****.**", entry);


            var mergeText = new List.Merges()
            {
                { "FNAME", nombre },
                { "LNAME", apPaterno }
            };
            //var merges = new List<List.Merges> { mergeText };

            var mcApi = new MCApi(apiKey, false);


            mcApi.ListSubscribe(listId, correo, mergeText, options);
            //mcApi.ListMergeVarAdd(listId, "Test", "Testing");


            //var lstMailChimp = mcApi.ListClients("e321ec7f9d");
            //mcApi.ListMembers("e321ec7f9d", List.MemberStatus.Subscribed).Data[1];
            //mcApi.ListSubscribe(listId, "*****@*****.**");

            //var listaClientes = mcApi.ListMembers(listId, List.MemberStatus.Subscribed).Data;
            //var lstMember = mcApi.ListMergeVars(listId);

            //foreach (var item in listaClientes)
            //{
            //    var email = item.Email;
            //    var description = item.Description;
            //    var reason = item.Reason;
            //    var timestamp = item.Timestamp;
            //}

            //foreach (var mergeVar in lstMember)
            //{
            //    var name = mergeVar.Name;
            //    var ejemplo = mergeVar.HelpText[0];
            //}
        }
Ejemplo n.º 6
0
        public static bool signup(string email, string firstName = null, string lastname = null)
        {
            if (email!=null)
            {
                MCApi mc = new MCApi(apiKey, true);

                if (mc.ListSubscribe("7c72db4561", email))
                {
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 7
0
		public bool AddToMailingList(string firstName, string lastName, string email, int list = 0)
		{
			MCApi server = new MCApi(mailingListToken, false);
			List.Merges merge_vars = new List.Merges();
			merge_vars.Add("fName", firstName);
			merge_vars.Add("lName", lastName);
			string mailChimpList;
			switch (list)
			{
				case 1: mailChimpList = mailChimpGeneralList; break;
				default: mailChimpList = mailChimpIBOList; break;
			}
			server.ListSubscribe(mailChimpIBOList, email, merge_vars);
			return false;
		}
 public bool AddOrUpdateSubscriber(string email, string list, string apiKey, string firstName, string lastName, string title, string company, string guid)
 {
     var mcApi = new MCApi(apiKey, true);
     var merges = new List.Merges();
     merges.Add("FNAME", firstName);
     merges.Add("LNAME", lastName);
     merges.Add("TITLE", title);
     merges.Add("COMPANY", company);
     merges.Add("GUID", guid);
     var subscriptionOptions = new List.SubscribeOptions();
     subscriptionOptions.UpdateExisting = true;
     subscriptionOptions.DoubleOptIn = false;
     subscriptionOptions.SendWelcome = false;
     return mcApi.ListSubscribe(list, email, merges, subscriptionOptions);
 }
        public bool Subscribe_NonPaidPlayers(PlayersExt model)
        {
            bool status = true;

            try
            {
                var mcApi = new MCApi(apiKey, false);

                //var lists = mcApi.Lists();

                //foreach (var item in lists.Data)
                //{
                //    string listID = item.ListID;
                //}

                List<List.Merges> SubscriptionInfo = new List<List.Merges>();

                var SubscriptionOptions = new MailChimp.Types.List.SubscribeOptions();
                SubscriptionOptions.DoubleOptIn = false;
                SubscriptionOptions.ReplaceInterests = false;
                SubscriptionOptions.EmailType = List.EmailType.Html;
                SubscriptionOptions.SendWelcome = false;
                SubscriptionOptions.UpdateExisting = true;

                var merges = GetListOfMerges(model);

                var returnvalue = mcApi.ListSubscribe(NonPaidPlayers_ListId, model.EmailAddress, merges, SubscriptionOptions);
            }
            catch (Exception ex)
            {
                if (IgnoreMailchimpErrors(ex.Message))
                { }
                else
                {
                    ErrorHandling.HandleException(ex);
                    status = false;
                }
            }

            return status;
        }
Ejemplo n.º 10
0
        public static bool testUserSignup(string email, string firstName, string lastName, string phone, string companyName, string cvr)
        {
            if (email != null && firstName != null && lastName != null && phone != null && companyName != null && cvr != null)
            {
                MCApi mc = new MCApi(apiKey, true);

                List.Merges merges = new List.Merges();
                merges.Add("FNAME", firstName);
                merges.Add("LNAME", lastName);
                merges.Add("CNAME", companyName);
                merges.Add("CVR", cvr);
                merges.Add("PHONE", phone);

                if (mc.ListSubscribe("908bfd3981", email, merges))
                {
                    return true;
                }
            }

            return false;
        }
        public EmailSubscriptionsOperationStatus SynchroniseSubscriptions(EmailSubscriptions subscriptions)
        {
            var operationStatus = new EmailSubscriptionsOperationStatus();
            try
            {
                MCApi api = new MCApi(_apiKey, false);
                var subscribeOptions =
                    new Opt<List.SubscribeOptions>(
                        new List.SubscribeOptions
                        {
                            SendWelcome = true,
                            UpdateExisting = true,
                            DoubleOptIn = (subscriptions.Subscriptions.Count() != 0),
                            //retain double optin for new subscribers
                            ReplaceInterests = true
                        });

                var groupings = new List<List.Grouping>()
                {
                    new List.Grouping("Signed Up As", subscriptions.Subscriptions.ToArray()),
                };

                var merges =
                    new Opt<List.Merges>(
                        new List.Merges
                        {
                            {"FNAME", subscriptions.ForeName},
                            {"LNAME", subscriptions.LastName},
                            {"GROUPINGS", groupings}
                        });

                operationStatus.Status = api.ListSubscribe(_listId, subscriptions.Email, merges, subscribeOptions);
                operationStatus.SubscriptionStatus = true;
            }
            catch (Exception e)
            {
                operationStatus = OperationStatusExceptionHelper<EmailSubscriptionsOperationStatus>
                    .CreateFromException("An error has occurred while syncing the email subscriptions", e);
                operationStatus.SubscriptionStatus = false;

            }
            return operationStatus;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// This function will add user to Mailchimp Subscription List
        /// </summary>
        /// <param name="emailId">EmailId of the user</param>
        /// <param name="firstName">First Name of the user</param>
        /// <param name="LastName">Last Name of the User</param>
        /// <param name="isSubscribeOnly">Checks if this is only subscribtion . while registering we'll add user to list , but we'll send subscription mail to user..in that case it'll be false.</param>
        /// <returns></returns>
        public string SaveToMailChimpList(string emailId, string firstName, string LastName,bool isSubscribeOnly)
        {
            MCApi api = new MCApi(ConfigurationManager.AppSettings["MailChimpApiKey"], false);

            List.Filter lf = new List.Filter();
            lf.ListName = ConfigurationManager.AppSettings["MailChimpListName"];
            List.Lists lists = api.Lists(lf);

            if (lists.Total > 0)
            {
                string listId = lists.Data[0].ListID;

                List.SubscribeOptions so = new List.SubscribeOptions();
                so.DoubleOptIn = false;

                List.Merges merges = new List.Merges();
                merges.Add("FNAME", firstName);
                merges.Add("LNAME", LastName);
                var uservailble = api.ListMemberInfo(listId, emailId);
                if (uservailble.Data[0].Email==null)
                {
                    if (api.ListSubscribe(listId, emailId, merges, so))
                    {
                        //send mail to user
                        if (isSubscribeOnly)
                        {
                            //send emailid in place of mail because name is empty in this case.
                            NotifyUser(emailId, emailId, "Thanks for showing interest in LockYourStay!", "Thank you for subscribing Lockyourstay.We will keep you posted with all updates.", "Notify User");
                        }
                        return "Thank you for your subscription!";
                    }
                    else
                    {
                        return "Something went wrong! Please try again later.";
                    }
                }
                else
                {
                    return "Email already exists!";
                }
            }
            else
            {
                //no list available
                return "Something went wrong! Please try again later.";
            }
        }
Ejemplo n.º 13
0
        public static bool AddMailChimpSubscriber(string email, string username, bool updateExisting, bool sendWelcome)
        {
            try
            {
                var mc = new MCApi(ConfigurationManager.AppSettings["MailChimpAPIKey"], true);

                var subscribedId   = ConfigurationManager.AppSettings["MailChimpSubscribedUsersListId"];
                var unsubscribedId = ConfigurationManager.AppSettings["MailChimpUnSubscribedUserListId"];
                if (updateExisting)
                {
                    var User = mc.ListMemberInfo(unsubscribedId, new List <string> {
                        email
                    });
                    if (User.Success.Value > 0)
                    {
                        MailChimpUnSubscribe(new List <string> {
                            email
                        }, unsubscribedId);
                    }
                }
                else
                {
                    var User = mc.ListMemberInfo(unsubscribedId, new List <string> {
                        email
                    });
                    if (User.Success.Value == 0)
                    {
                        var SubUser = mc.ListMemberInfo(subscribedId, new List <string> {
                            email
                        });
                        if (SubUser.Success.Value > 0)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }

                var subscribeOptions =
                    new Opt <List.SubscribeOptions>(
                        new List.SubscribeOptions
                {
                    DoubleOptIn    = false,
                    SendWelcome    = sendWelcome,
                    UpdateExisting = updateExisting,
                });
                var merges = new Opt <List.Merges>(
                    new List.Merges
                {
                    { "FNAME", username },
                });
                return(mc.ListSubscribe(updateExisting ? subscribedId : unsubscribedId, email, merges, subscribeOptions));
            }
            catch
            {
                return(false);
            }
        }