public ActionResult Update(string id)
        {
            var defaultEvent = service.GetDefaultEvent();
            int eventid = defaultEvent.ID;
            MailChimpManager mc = new MailChimpManager(_mailchimpKey);
            ListInfo mailingList = mc.GetLists().Data.Where(l=>l.Id==id).SingleOrDefault();
            List<BatchEmailParameter> batchList = new List<BatchEmailParameter>();
            if (mailingList.Name.Contains("Speakers"))
            {
                foreach (var speaker in service.GetSpeakers(eventid))
                {
                    MyMergeVar myMergeVars = new MyMergeVar();
                    myMergeVars.FirstName = speaker.FirstName;
                    myMergeVars.LastName = speaker.LastName;           //  Create the email parameter
                    BatchEmailParameter batchEmail = new BatchEmailParameter();
                    EmailParameter email = new EmailParameter()
                    {
                        Email = speaker.Email

                    };
                    batchEmail.Email = email;
                    batchEmail.MergeVars = myMergeVars;

                    batchList.Add(batchEmail);
                }
            }
            if (mailingList.Name.Contains("Attendees"))
            {
                foreach (var attendee in service.GetAllAttendees(eventid))
                {
                    MyMergeVar myMergeVars = new MyMergeVar();
                    myMergeVars.FirstName = attendee.FirstName;
                    myMergeVars.LastName = attendee.LastName;           //  Create the email parameter
                    EmailParameter email = new EmailParameter()
                    {
                        Email = attendee.Email
                    };
                    BatchEmailParameter batchEmail = new BatchEmailParameter();
                    batchEmail.Email = email;
                    batchEmail.MergeVars = myMergeVars;

                    batchList.Add(batchEmail);

                }

            }
            BatchSubscribeResult bResult = mc.BatchSubscribe(id, batchList, false, true, true);
            //MyMergeVar myMergeVars = new MyMergeVar();
            //myMergeVars.FirstName = subscriber.FirstName;
            //myMergeVars.LastName = subscriber.LastName;           //  Create the email parameter
            //EmailParameter email = new EmailParameter()
            //{
            //    Email = subscriber.EmailAddress
            //};

            //EmailParameter results = mc.Subscribe(_mailchimpGroupId, email, myMergeVars);

            return RedirectToAction("Index");
        }
Пример #2
0
        private static void BatchSubscribe()
        {
            MailChimpManager mc = new MailChimpManager("e20533551f21cbc6b07c76e570dc33c4-us11");
               ListResult lists = mc.GetLists();
               //1fe090facf
            List<BatchEmailParameter> emails = new List<BatchEmailParameter>();

            BatchEmailParameter email1 = new BatchEmailParameter()
            {
                Email = new EmailParameter()
                {
                    Email = "*****@*****.**"
                }
            };

            MergeVar mVar1 = new MergeVar();
            mVar1.Add("FNAME", "first1" + DateTime.Now);
            mVar1.Add("LNAME", "last1" + DateTime.Now);
            email1.MergeVars = mVar1;

            emails.Add(email1);
        }
Пример #3
0
        public void BatchSubscribe_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();

            List<BatchEmailParameter> emails = new List<BatchEmailParameter>();

            BatchEmailParameter email1 = new BatchEmailParameter()
            {
                Email = new EmailParameter()
                {
                    Email = "*****@*****.**"
                }
            };

            BatchEmailParameter email2 = new BatchEmailParameter()
            {
                Email = new EmailParameter()
                {
                    Email = "*****@*****.**"
                }
            };

            emails.Add(email1);
            emails.Add(email2);

            //  Act
            BatchSubscribeResult results = mc.BatchSubscribe(lists.Data[1].Id, emails);

            //  Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(results.AddCount == 2);
        }
Пример #4
0
        public void BatchSubscribe_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult lists = mc.GetLists();

            List<BatchEmailParameter> emails = new List<BatchEmailParameter>();

            BatchEmailParameter email1 = new BatchEmailParameter()
            {
                Email = new EmailParameter()
                {
                    Email = "*****@*****.**"
                }
            };
						MergeVar mVar1 = new MergeVar();
						mVar1.Add("FNAME", "first1" + DateTime.Now);
						mVar1.Add("LNAME", "last1" + DateTime.Now);
						email1.MergeVars = mVar1;
						emails.Add(email1);

            BatchEmailParameter email2 = new BatchEmailParameter()
            {
                Email = new EmailParameter()
                {
                    Email = "*****@*****.**"
                }
            };
						MergeVar mVar2 = new MergeVar();
						mVar2.Add("FNAME", "first2" + DateTime.Now);
						mVar2.Add("LNAME", "last2" + DateTime.Now);
						email2.MergeVars = mVar2;
            emails.Add(email2);

            //  Act
            BatchSubscribeResult results = mc.BatchSubscribe(lists.Data[0].Id, emails);

            //  Assert
            Assert.IsNotNull(results);
            Assert.IsTrue(results.AddCount == 2);

						// load
						List<EmailParameter> emailsP = new List<EmailParameter>();
						emailsP.Add(email1.Email);
						MemberInfoResult memberInfo = mc.GetMemberInfo(lists.Data[0].Id, emailsP);
						Assert.AreEqual(mVar1["FNAME"], memberInfo.Data[0].MemberMergeInfo["FNAME"]);
						Assert.AreEqual(mVar1["LNAME"], memberInfo.Data[0].MemberMergeInfo["LNAME"]);

        }