Example #1
0
        public virtual async Task<ActionResult> Create(NewUserViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var user = new AuthenticatedUser(model.UserName, model.Email);
            var result = await _userManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                return RedirectToAction("success");
            }
            else
            {
                foreach (var errorMessage in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, errorMessage);
                }

                return View(model);
            }
        }
Example #2
0
 public virtual ActionResult Create()
 {
     var model = new NewUserViewModel();
     return View(model);
 }