Beispiel #1
0
        public async Task <IActionResult> Edit(string id)
        {
            try
            {
                var token = _session.GetString("Token");
                if (Seguridad.validarUsuarioAdministrativo(token))
                {
                    Chofer chofer = await _controladoraUsuarios.getChofer(id);

                    if (chofer == null)
                    {
                        ModelState.AddModelError(string.Empty, "Ha ocurrido un error inesperado, intente de nuevo mas tarde");
                        return(RedirectToAction("Index"));
                    }
                    ViewModelChofer editar = new ViewModelChofer();
                    editar.Chofer          = chofer;
                    editar.Chofer.Password = chofer.Password;
                    editar.Libreta         = chofer.LibretaDeConducir;
                    editar.Id = chofer.Id.ToString();
                    return(View(editar));
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
            catch (MensajeException msg)
            {
                TempData["Error"] = msg.Message;
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                TempData["Error"] = "Se produjo un error inesperado. Intente de nuevo mas tarde";
                return(RedirectToAction("Index"));
            }
        }