public ActionResult SignUp(RequiredInfoViewModel requiredInfoViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(requiredInfoViewModel);
            }

            var subDomain = GetSubDomainFromCharityName(requiredInfoViewModel.CharityName);
            var activationToken = TokenHelper.CreateRandomIdentifier();

            var registrationInfo = new RegistrationInfo();
            Mapper.DynamicMap(requiredInfoViewModel, registrationInfo);

            var result = _charityMembershipService.RegisterUserAndCharity(registrationInfo);

            if (result)
            {
                var emailViewModel = new EmailViewModel
                                         {
                                             To = requiredInfoViewModel.UserIdentifier,
                                             ActivationToken = activationToken.AsQueryString()
                                         };

                signUpQueueingService.QueueEmail(emailViewModel);
                signUpQueueingService.QueueProvisioning();

                TempData["SubDomain"] = subDomain;

                return RedirectToAction("Complete");
            }

            ModelState.AddModelError("", "User and Charity registration failed. Please contact support.");
            return View();
        }
        public ActionResult SignUp(RequiredInfoViewModel requiredInfoViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(requiredInfoViewModel);
            }

            var subDomain = GetSubDomainFromCharityName(requiredInfoViewModel.CharityName);
            var activationToken = TokenHelper.CreateRandomIdentifier();

            //TODO subDomain should be stored to database
            Session[activationToken.AsQueryString()] = subDomain;

            /*
            Add membership record inc. domain information
            */
            var emailViewModel = new EmailViewModel
                                     {
                                         To = requiredInfoViewModel.UserIdentifier,
                                         ActivationToken = activationToken.AsQueryString()
                                     };

            signUpQueueingService.QueueEmail(emailViewModel);
            signUpQueueingService.QueueProvisioning();

            TempData["SubDomain"] = subDomain;

            return RedirectToAction("Complete");
        }
        public void SignUp_WithSuccessfulStore_RedirectsToComplete()
        {
            var requiredInfoViewModel = new RequiredInfoViewModel
                                            {
                                                UserIdentifier = "A",
                                                Password = "******",
                                                CharityName = "C",
                                            };

            var controller = new SignUpController(configuration, signUpQueueingService, charityMembershipService);
            charityMembershipService.RegisterUserAndCharity(null).ReturnsForAnyArgs(true);
            var result = controller.SignUp(requiredInfoViewModel);
            result.AssertActionRedirect().ToAction("Complete");
        }
        public void SignUp_WithUnsuccessfulStore_RendersView()
        {
            var requiredInfoViewModel = new RequiredInfoViewModel
                                            {
                                                UserIdentifier = "A",
                                                Password = "******",
                                                CharityName = "C",
                                            };

            var controller = new SignUpController(configuration, signUpQueueingService, charityMembershipService);
            charityMembershipService.RegisterUserAndCharity(null).ReturnsForAnyArgs(false);
            var result = controller.SignUp(requiredInfoViewModel);
            
            result.AssertViewRendered();
        }