public async Task <ActionResult> registration(RegisterViewModel regModel) { if (!ModelState.IsValid) { if (regModel.UserName != null && _userService.UserNameExists(regModel.UserName)) { ModelState.AddModelError("UserName", "user with such a UserName exists"); } return(View(regModel)); } IdentityResult regResult = _userService.Create(regModel.UserName, regModel.Email, regModel.Password, "user"); if (regResult.Succeeded) { var user = _userService.FindUserByName(regModel.UserName); string callbackUrl = Url.Action("ConfirmEmail", "account", null, Request.Url.Scheme); await _userService.EmailConfirmed(user.Id, callbackUrl); _cusomerService.CreateCustomerProfile(user.Id); _commitProvider.SaveChanges(); return(RedirectToAction("DisplayEmail", "account")); } AddModeErrors(regResult); return(View(regModel)); }