public ActionResult SignUp(SignUpViewModel vm)
        {
            if (!ModelState.IsValid)
                return View();
            bool success = SaveCharity(vm);

            return RedirectToAction(success ? "thankyou" : "SignUp");
        }
        private bool SaveCharity(SignUpViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var charity = vm.MapToCharityModel();
                _charityRepository.Save(charity);
                _notificationService.SendNotification(vm.Email, VolunteerNotificationTemplate.WelcomeVolunteer);

                return true;
            }
            return false;
        }
        public void SignUpAction_Post_Redirects()
        {
            //Arrange
            var model = new SignUpViewModel();
            _charityRepository.Save(new Charity());
            _notificationService.SendNotification(string.Empty, VolunteerNotificationTemplate.WelcomeVolunteer).Returns(true);

            //Act
            var controller = new CharityController(_charityRepository, _notificationService);
            var result = controller.SignUp(model);

            //Assert
            result.AssertActionRedirect();
        }
        public void SignUpAction_Post__With_ModelError_Returns_View()
        {
            //Arrange
            var model = new SignUpViewModel();
            _charityRepository.Save(new Charity());
            _notificationService.SendNotification(string.Empty, VolunteerNotificationTemplate.WelcomeVolunteer).Returns(true);

            //Act
            var controller = new CharityController(_charityRepository, _notificationService);
            controller.ModelState.AddModelError("An Error", "Message");
            var result = controller.SignUp(model);

            //Assert
            result.AssertViewRendered();
        }
Example #5
0
        public static GiveCampLondon.Charity MapToCharityModel(this Charity.SignUpViewModel vm)
        {
            var charity = new GiveCampLondon.Charity
            {
                CharityName           = vm.Name,
                BackgroundInformation = vm.BackgroundInformation,
                OtherInfrastructure   = vm.OtherInfrastructure,
                OtherSupportSkills    = vm.OtherSupportSkills,
                WorkRequested         = vm.WorkRequested,
                Email        = vm.Email,
                Website      = vm.Website,
                ContactName  = vm.ContactName,
                ContactPhone = vm.ContactPhone,
                Approved     = false
            };

            return(charity);
        }