예제 #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 ActionResult ResendEmailConfirmation(string email)
        {
            var user = userService.GetUserByNewEmail(email);
            user.SetNewEmail(user.NewEmail);
            unitOfWork.Save();

            using (var sendEmail = 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("EmailConfirmation", emailModel);
                sendEmail.CreateEmail(new MailAddress(user.GetEmail()), "Confirm Your Email - FlashMercy", emailMessage);
                sendEmail.Send();
            }

            return RedirectToAction("EmailConfirmationSent");
        }