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(); }
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)); //} }
//[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(); //} }