Пример #1
0
        public ActionResult SignUp(SignUpViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.CreateRegionOptions(metroRegionService.GetRegions());
                return View(model);
            }

            var user = model.ToUser(metroRegionService);

            try
            {
                userService.SignUpUser(user);
            }
            catch (ArgumentException ae)
            {
                ModelState.AddModelError("Email", ae.Message);
                model.CreateRegionOptions(metroRegionService.GetRegions());
                return View(model);
            }

            // saves new user
            unitOfWork.Save();

            // login new user
            webSecurity.Login(model.Email, model.Password);

            using (var email = new SendEmail())
            {
                var emailModel = new
                {
                    firstName = user.UserProfile.FirstName,
                    urlAuthority = this.HttpContext.Request.Url.Authority,
                    confirmationKey = user.NewEmailConfirmationKey
                };

                var emailMessageFactory = new Email.MessageFactory();
                var emailMessage = emailMessageFactory.BuildMessage("SignUpEmailConfirmation", emailModel);
                email.CreateEmail(new MailAddress(user.GetEmail()), "Welcome to FlashMercy", emailMessage);
                email.Send();
            }

            TempData.AddAlert("Thank you for signing up. Please check your inbox for a confirmation sendEmail.");

            return RedirectToAction("DashBoard", "Members");
        }
Пример #2
0
 public ViewResult SignUp()
 {
     var model = new SignUpViewModel();
     model.CreateRegionOptions(metroRegionService.GetRegions());
     return View(model);
 }