public async Task <IActionResult> Create(CreateModel model, Excerciser excerciser) { if (ModelState.IsValid) { AppUser user = new AppUser { UserName = model.Name, Email = model.Email }; excerciser.UserName = model.Name; excerciser.Email = model.Email; string newPassWord = model.Password; excerciser.userPassword = Encrypt.CreateMD5(newPassWord); _context.Excerciser.Add(excerciser); _context.SaveChanges(); IdentityResult result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { return(RedirectToAction("Index")); } else { foreach (IdentityError error in result.Errors) { ModelState.AddModelError("", error.Description); } } } return(View(model)); }