Beispiel #1
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            IdentityResult result = new IdentityResult();

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, AccountType = AccountType.Business
                };

                result = UserManager.Create(user, model.Password);
                if (result.Succeeded)
                {
                    _businessService.CreateBusinessInfo(user.Id, model.BusinessName, model.Lat, model.Lng, model.FormattedAddress, model.PhoneNumber, model.FormattedPhoneNumber, model.Website, model.Rating, model.PlaceId);
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    _emailService.SendRequireEmailValidation(model.Email, ConfigurationManager.AppSettings["ContactEmailAddress"], model.BusinessName, callbackUrl);

                    return(View("RequireEmailVerification"));
                }
            }
            ModelState.AddModelError("", "This email address has already been registered to another user.");
            return(View());
        }