Ejemplo n.º 1
0
        public IActionResult GetAuthentication([FromBody] DTOUserCredentials body)
        {
            try
            {
                var validator        = new UserAuthenticationValidation();
                var rusultValidation = validator.Validate(body);
                if (!rusultValidation.IsValid)
                {
                    return(BadRequest(rusultValidation.Errors));
                }

                var resultAuthentication = _authService.Execute(body);
                if (resultAuthentication != null)
                {
                    var dto = _mapper.Map <DTOResultAuthentication>(resultAuthentication);
                    return(Ok(dto));
                }
                return(BadRequest("Email ou senha invalido tente novamente."));
            }
            catch
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ErroMessage));
            }
        }