Ejemplo n.º 1
0
            // Helpers.

            private async Task <PaginatedList <ContactDto> > ReadFromDatabase(ContactsQuery query, object key)
            {
                return(await _context.Contacts
                       .Where(e => e.OwnerUserId == query.OwnerUserId)
                       .ProjectTo <ContactDto>(_mapper.ConfigurationProvider)
                       .ProjectToPaginatedListAsync(query.PageNumber, query.PageSize)
                       .MapUsersAsync(_usersFacade)
                       .Cache(_cache, key));
            }
Ejemplo n.º 2
0
            public async Task <PaginatedList <ContactDto> > Handle(ContactsQuery query,
                                                                   CancellationToken cancellationToken)
            {
                var key = query.Identify();

                try
                {
                    _logger.LogInformation("[WLODZIMIERZ.API / Users] Reading from the cache: {Name} {@Query}",
                                           nameof(ContactsQuery), query);

                    return(await ReadFromCache(key));
                }
                catch (NotFoundException)
                {
                    _logger.LogWarning("[WLODZIMIERZ.API / Users] No entry found for the passed key in the cache");

                    _logger.LogInformation("[WLODZIMIERZ.API / Users] Reading from the database: {Name} {@Query}",
                                           nameof(ContactsQuery), query);

                    return(await ReadFromDatabase(query, key));
                }
            }