Esempio n. 1
0
        public IniciarSesionResponse Post([FromBody] IniciarSesionRequest SessionObject)
        {
            var RG = new RespuestaTransaccion();
            IniciarSesionResponse ObjetoRespuesta = null;
            RespuestaTransaccion  RTN             = new RespuestaTransaccion();

            using (FacturadorWebContext context = new FacturadorWebContext())
            {
                var query_sesion = from U in context.Usuario join P in context.Persona on U.IdPersona equals P.Id where U.Nickname == SessionObject.NICKNAME && U.Clave == SessionObject.PASSWORD
                                   select new IniciarSesionResponse {
                    NOMBRE = P.Nombre, APELLIDO = P.Apellido, ID_USUARIO = U.Id, PERFIL = U.Perfil, ESTADO = U.Estado
                };
                ObjetoRespuesta = query_sesion.FirstOrDefault();

                if (ObjetoRespuesta != null)
                {
                    if (ObjetoRespuesta.ESTADO)
                    {
                        ObjetoRespuesta.RESPUESTA_TRANSACCION = RTN.GenerarRespuesta("Transaccion exitosa", "0000");
                    }
                    else
                    {
                        ObjetoRespuesta.RESPUESTA_TRANSACCION = RTN.GenerarRespuesta("Error. Usuario inactivo, por favor contacte al administrador del sistema", "0008");
                    }
                }
                else
                {
                    ObjetoRespuesta = new IniciarSesionResponse();
                    ObjetoRespuesta.RESPUESTA_TRANSACCION = RTN.GenerarRespuesta("Error. Inicio de sesion fallido, usuario o password incorrectos", "0007");
                }
                return(ObjetoRespuesta);
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> PostIniciarSesion(IniciarSesionRequest request)
        {
            var command = new IniciarSesionCommand(request.NombreDeUsuario, request.Contrasenia, request.Recordarme);

            await this.mediator.Send(command);

            return(this.Ok());
        }
Esempio n. 3
0
        public async Task IniciarSesion(IniciarSesionRequest iniciarSesionRequest)
        {
            var resultado = await this.httpClient.PostAsJsonAsync("api/auth/iniciar-sesion", iniciarSesionRequest);

            if (resultado.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                throw new Exception(await resultado.Content.ReadAsStringAsync());
            }

            resultado.EnsureSuccessStatusCode();
        }
        public async Task IniciarSesion(IniciarSesionRequest loginParameters)
        {
            await this.authApi.IniciarSesion(loginParameters);

            this.NotifyAuthenticationStateChanged(this.GetAuthenticationStateAsync());
        }