public void SendAuthorizationNote_Returns_Redirect()
        {
            var model = new AuthorizeModel
                            {
                                ActivationHash = "goodHash",
                                Email = "goodEmail",
                                FirstName = "Jonny",
                                LastName = "Appleseed",
                                SenderEmail = "senderEmail",
                                SenderName = "senderName",
                                Url = "goodUrl"
                            };

            var result = controller.SendAuthorizationNote(model);
            Assert.IsInstanceOf(typeof(RedirectToRouteResult), result);
        }
        public ActionResult SendAuthorizationNote(AuthorizeModel model)
        {
            using (userProfileRepository)
            {
                var userProfile = userProfileRepository.FindUserProfileByEmail(model.Email).FirstOrDefault();
                var organization = OrganizationRepository.GetDefaultOrganization(readOnly: true);

                if (userProfile == null)
                {
                    TempData["UserFeedback"] = "We couldn't find that email address in our system. Are you sure that was the right one?";
                    return RedirectToAction("AwaitingActivation", "Account");
                }

                var service = new GrassrootsMembershipService();
                userProfile.ActivationHash = service.GetUserAuthorizationHash();
                userProfile.LastActivationAttempt = DateTime.Now;
                userProfileRepository.Save();
                accountMailer.Authorize(MapAuthorizeModel(userProfile, organization)).SendAsync();
            }

            TempData["UserFeedback"] = "We just sent you an email. Check your email account and follow the instructions inside.";
            return RedirectToAction("AwaitingActivation", "Account");
        }