Exemplo n.º 1
0
        public async Task <IActionResult> Signin([FromBody] TokenRequest request)
        {
            var result = new ApiResponse <CredentialResponse>();

            if (!ModelState.IsValid)
            {
                result.AddError(ModelState);
                return(Ok(result));
            }

            var authWithToken = await authneticateService.IsAuthenticatedAsync(request);

            if (authWithToken.IsAuthenticated)
            {
                var credentialReponse = new CredentialResponse
                {
                    Token = authWithToken.Token
                };

                result.AddData(credentialReponse);

                return(Ok(result));
            }

            result.AddError("Invalid Account");

            return(Ok(result));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetBlogs()
        {
            var result = new ApiResponse <IEnumerable <Blog> >();

            var data = await blogService.GetBlogs();

            result.AddData(data);

            return(Ok(result));
        }