public async Task <IActionResult> RegistrarUsuario(Usuarios user) { if (ModelState.IsValid) { List <CustomValidationResult> validaciones = await repo.Validate(user); if (validaciones != null && validaciones.Count > 0) { foreach (CustomValidationResult vali in validaciones) { foreach (string v in vali.MemberNames) { if (v == "Email") { ViewData["validarEmail"] = vali.ErrorMessage; return(View()); } } } } Role role; string email = user.Email; string password = user.Password; string confirmPassword = user.ComparePassword; if (user.Role == 0) { role = Role.Paciente; } else { role = user.Role; } await repo.CrearUsuario(email, password, confirmPassword, role); if (User.IsInRole("Administrador")) { return(RedirectToAction("ListaUsuarios", "Administrador")); } return(RedirectToAction("Index", "Home")); } else { return(View()); } }
public void CrearUsuario(Usuarios user) { repo.CrearUsuario(user.Email, user.Password, user.ComparePassword, user.Role); }