Пример #1
0
        public bool Complete(OnboardToken t)
        {
            ICustomerRepository custRepo = RepoFactory.GetCustomerRepo();

            Customer c = custRepo.GetWithID(t.CustomerID);

            Customer custCheck = custRepo.GetWithEmailAddress(t.EmailAddress.ToLower().Trim());

            c.Type = (int)Customer.TypeCodes.Default;

            // check for email address in use
            if (custCheck != null && custCheck.Type != (int)Customer.TypeCodes.Unclaimed)
            {
                Security s = new Security();

                Authorization a = s.AuthorizeCustomer(new Login { EmailAddress = t.EmailAddress, Password = t.Password });
                if (a != null && a.Valid)
                {
                    System.Diagnostics.Trace.WriteLine("Moving challenges from " + c.ID.ToString() + " to " + a.CustomerID.ToString());

                    // zomg u're real
                    custRepo.AddForeignNetworkForCustomer(a.CustomerID, t.ForeignUserID, (Customer.ForeignUserTypes)t.AccountType);

                    // we need to collapse the unclaimed account into the one we just found.
                    RepoFactory.GetChallengeRepo().MoveChallengesToCustomer(c.ID, a.CustomerID);
                    RepoFactory.GetChallengeStatusRepo().MoveStatusesToNewCustomer(c.ID, a.CustomerID);

                    // now that we've moved the challenges, delete the original customer
                    custRepo.Remove(c.ID);

                    return true;
                }
                else
                    return false;
            }
            else if (custCheck != null && custCheck.Type == (int)Customer.TypeCodes.Unclaimed)
            {
                c = custCheck;
                c.Type = (int)Customer.TypeCodes.IncompleteOnboard;
            }

            c.EmailAddress = t.EmailAddress.ToLower().Trim();
            c.FirstName = t.FirstName;
            c.LastName = t.LastName;
            c.Password = t.Password;

            custRepo.Update(c);
            custRepo.AddForeignNetworkForCustomer(c.ID, t.ForeignUserID, (Customer.ForeignUserTypes)t.AccountType);

            if (t.ChallengeID != 0)
            {
                DareManager dmgr = new DareManager();
                dmgr.Accept(t.ChallengeID, c.ID);
            }

            return true;
        }
Пример #2
0
 public OnboardController()
 {
     _fb = new FacebookClient();
     _obm = new OnboardManager();
     _dmgr = new DareManager();
 }
Пример #3
0
        public ActionResult Sms(SmsRequest request)
        {
            var response = new TwilioResponse();

            string[] validNumbers = new string[] { "+18508032974", "+13237071329" };

            if (!validNumbers.Contains<string>(request.From))
            {
                response.Sms("Hi, I'm not allowed to talk to strangers. Please visit http://dareme.to.");
                return new TwiMLResult(response);
            }

            string[] parsed=request.Body.Split(new char[] { ' ' });
            if (parsed==null || parsed.Length < 2)
            {
                response.Sms("That's not a valid command. :-/");
                return new TwiMLResult(response);
            }

            DareManager dareMgr = new DareManager();

            switch (parsed[0].ToUpper())
            {
                case "MOD":
                    dareMgr.Takedown(Convert.ToInt64(parsed[1]));
                    break;
                default:
                    response.Sms("That's not a valid command. :-\\");
                    break;
            }

            return new TwiMLResult(response);
        }
Пример #4
0
 public void Takedown(long id)
 {
     DareManager dareMgr = new DareManager();
     dareMgr.Takedown(id);
     dareMgr = null;
 }