示例#1
0
        public async Task <IActionResult> Register(string language, RegisterViewModel model)
        {
            if (!CultureUtility.SetCurrentThreadCulture(language))
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var userCreationResult = await _userManager.CreateAsync(AppUser.CreateFromRegisterViewModel(model), model.Password);

            if (userCreationResult.Succeeded)
            {
                return(RedirectToAction("SignIn", "Login"));
            }

            foreach (var error in userCreationResult.Errors)
            {
                ModelState.AddModelError(string.Empty, error.Description);
            }

            return(View(model));
        }