public async Task <IActionResult> Create(ViewModelChofer model) { try { var token = _session.GetString("Token"); if (Seguridad.validarUsuarioAdministrativo(token)) { if (ModelState.IsValid) { if (model.ConfirmarContraseña.Equals(model.Chofer.Password)) { Chofer chofer = await _controladoraUsuarios.CrearChofer(model.Chofer, model.Libreta); if (chofer != null) { return(RedirectToAction("Index")); } return(View(model)); } else { ModelState.AddModelError(string.Empty, "Las contraseñas deben coincidir"); return(View(model)); } } else { return(View(model)); } } else { return(RedirectToAction("Login", "Account")); } } catch (MensajeException msg) { ModelState.AddModelError(string.Empty, msg.Message); return(View(model)); } catch (Exception) { ModelState.AddModelError(string.Empty, "Se produjo un error inesperado. Intente de nuevo mas tarde"); return(View(model)); } }