private void HandleEmailNotifications(long SourceCustomerID, long TargetCustomerID, long ChallengeID, CustomerNotifier.NotifyType Type)
        {
            Customer sourceCust;
            Customer targetCust;
            Challenge chal;

            targetCust = RepoFactory.GetCustomerRepo().GetWithID(TargetCustomerID);
            sourceCust = RepoFactory.GetCustomerRepo().GetWithID(SourceCustomerID);
            chal = RepoFactory.GetChallengeRepo().Get(ChallengeID);

            EmailNotifyModel m = new EmailNotifyModel { Challenge = chal, SourceCustomer = sourceCust, TargetCustomer = targetCust };

            string template = null;
            string output = null;
            string email = null;
            string subject = null;

            try
            {
                switch (Type)
                {
                    case CustomerNotifier.NotifyType.ChallengeAccepted:
                        template = File.OpenText("ChallengeAccepted.email").ReadToEnd();
                        output = Razor.Parse(template, m);
                        email = sourceCust.EmailAddress;
                        subject = targetCust.FirstName+" has taken your dare";
                        break;
                    case CustomerNotifier.NotifyType.ChallengeAwardedToYou:
                        template = File.OpenText("ChallengeAwardedToYou.email").ReadToEnd();
                        output = Razor.Parse(template, m);
                        email = targetCust.EmailAddress;
                        subject = "You've been awarded a bounty!";
                        break;
                    case CustomerNotifier.NotifyType.ChallengeBacked:
                        template = File.OpenText("ChallengeBacked.email").ReadToEnd();
                        output = Razor.Parse(template, m);
                        email = targetCust.EmailAddress;
                        subject = sourceCust.FirstName + " has backed one of your dares";
                        break;
                    case CustomerNotifier.NotifyType.ChallengeClaimed:
                        template = File.OpenText("ChallengeClaimed.email").ReadToEnd();
                        output = Razor.Parse(template, m);
                        email = sourceCust.EmailAddress;
                        subject = targetCust.FirstName + " thinks he's completed your dare";
                        break;
                    case CustomerNotifier.NotifyType.ChallengeRejected:
                        template = File.OpenText("ChallengeRejected.email").ReadToEnd();
                        output = Razor.Parse(template, m);
                        email = sourceCust.EmailAddress;
                        subject = targetCust.FirstName + " has rejected your dare";
                        break;
                    case CustomerNotifier.NotifyType.ChallengeYouBackedAwardedAssented:
                        break;
                    case CustomerNotifier.NotifyType.ChallengeYouBackedAwardedDissented:
                        break;
                    case CustomerNotifier.NotifyType.NewChallenge:
                        template = File.OpenText("NewChallenge.email").ReadToEnd();
                        output = Razor.Parse(template, m);
                        email = targetCust.EmailAddress;
                        subject = "You've been dared by " + sourceCust.FirstName;
                        break;
                    case CustomerNotifier.NotifyType.ChallengeModeratorTakeDown:
                        template = File.OpenText("Takedown.email").ReadToEnd();
                        output = Razor.Parse(template, m);
                        email = targetCust.EmailAddress;
                        subject = "Your dare has been taken down by a moderator";
                        break;
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("EMAIL PARSE EXCEPTION: " + e.ToString());
            }

            try
            {
                if (output != null && !output.Equals(""))
                {
                    var message = SendGrid.GenerateInstance();
                    message.AddTo(email);
                    message.From = new System.Net.Mail.MailAddress("*****@*****.**", "dareme.to");
                    message.Cc = new System.Net.Mail.MailAddress[] { new System.Net.Mail.MailAddress("*****@*****.**") };
                    message.Html = output;
                    message.Subject = subject;
                    var transport = SendGridMail.Transport.SMTP.GenerateInstance(new System.Net.NetworkCredential("daremeto", "3f!margarita"));
                    transport.Deliver(message);
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("EMAIL SEND EXCEPTION: " + e.ToString());
            }
        }
        private void HandlePushServiceNotifications(long SourceCustomerID, long TargetCustomerID, long ChallengeID, CustomerNotifier.NotifyType Type)
        {
            Customer c;

            switch (Type)
            {
                case CustomerNotifier.NotifyType.ChallengeAccepted:         // source, target
                    c = RepoFactory.GetCustomerRepo().GetWithID(TargetCustomerID);
                    PushToCustomer(SourceCustomerID,  c.FirstName+" has taken your dare!", ChallengeID);
                    break;
                case CustomerNotifier.NotifyType.ChallengeAwardedToYou:     // target
                    PushToCustomer(TargetCustomerID, "A dare you've attempted has been awarded to you!", ChallengeID);
                    break;
                case CustomerNotifier.NotifyType.ChallengeBacked:           // source, target
                    c = RepoFactory.GetCustomerRepo().GetWithID(SourceCustomerID);
                    PushToCustomer(TargetCustomerID, c.FirstName+" has backed one of your dares!", ChallengeID);
                    break;
                case CustomerNotifier.NotifyType.ChallengeClaimed:          // source, target
                    c = RepoFactory.GetCustomerRepo().GetWithID(TargetCustomerID);
                    PushToCustomer(SourceCustomerID, c.FirstName+" claims to have completed a dare you issued", ChallengeID);
                    break;
                case CustomerNotifier.NotifyType.ChallengeRejected:         // target

                    break;
                case CustomerNotifier.NotifyType.ChallengeYouBackedAwardedAssented: // target

                    break;
                case CustomerNotifier.NotifyType.ChallengeYouBackedAwardedDissented: // target

                    break;
                case CustomerNotifier.NotifyType.NewChallenge:              // source, target
                    c = RepoFactory.GetCustomerRepo().GetWithID(SourceCustomerID);
                    PushToCustomer(TargetCustomerID, c.FirstName+" has dared you to do something!", ChallengeID);
                    break;
            }
        }