Exemplo n.º 1
0
        public async Task <IEnumerable <BookModel> > GetBooks(bool throwException = false)
        {
            try
            {
                var userId = User.Claims.FirstOrDefault(c => c.Type == "sub")?.Value;

                _logger.LogInformation("{UserId} is inside get all books API call. {claims}", userId, User.Claims);

                //var userId = User.Claims.FirstOrDefault(a => a.Type == "sub")?.Value;
                //var oath2Scopes = string.Join(',',
                //    User.Claims.Where(c => c.Type == "scope")?.Select(c => c.Value));

                //using (_logger.BeginScope("{UserId} {OAuth2Scopes}", userId, oath2Scopes))
                //using (_logger.BeginScope(_scopeInfo.HostScopeInfo))
                //{

                return(await _bookLogic.GetAllBooks(throwException));

                //}
            } catch (Exception ex)
            {
                _logger.LogError(ex, "Error retrieving books info");
                return(new List <BookModel>().AsEnumerable());
            }
        }
        public async Task <IEnumerable <BookModel> > GetBooks()
        {
            var userId = User.Claims.FirstOrDefault(a => a.Type == "sub")?.Value;

            _logger.LogInformation("{userId} is inside get all books API call. {claims}",
                                   userId, User.Claims);

            return(await _bookLogic.GetAllBooks());

            //return _bookRepo.GetAllBooksThrowError();
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <BookModel> > GetBooks(bool throwException = false)
        {
            //var userId = User.Claims.FirstOrDefault(a => a.Type == "sub")?.Value;
            //var oath2Scopes = string.Join(',',
            //    User.Claims.Where(c => c.Type == "scope")?.Select(c => c.Value));

            //using (_logger.BeginScope("{UserId} {OAuth2Scopes}", userId, oath2Scopes))
            //using (_logger.BeginScope(_scopeInfo.HostScopeInfo))
            //{
            _logger.LogInformation("API ENTRY: Inside get all books API call.");
            return(await _bookLogic.GetAllBooks(throwException));

            //}
        }
Exemplo n.º 4
0
        //[Route("Books")]
        public async Task <IEnumerable <BookModel> > GetBooks()
        {
            var userId = User.Claims.FirstOrDefault(a => a.Type == "sub")?.Value;

            _logger.LogInformation("{UserId} is inside get all books API call.  {claims}", userId, User.Claims);
            _logger.LogError("error occures!");
            return(await _bookLogic.GetAllBooks());


            //using (_logger.BeginScope("Constructing books response for {ScopedUserId}", userId))
            //using (_logger.ApiGetAllBooksScope(userId))
            //{
            //    return await _bookLogic.GetAllBooks();
            //}
        }