Beispiel #1
0
        public Task HandleAsync(TeamLogCreatedEvent @event, CancellationToken cancellationToken)
        {
            _cache.Remove(_cacheKey.CountTeamLogs
                          (
                              @event.TeamId
                          ));

            return(Task.CompletedTask);
        }
        public async Task <CountTeamLogsProjection> HandleAsync(CountTeamLogsQuery query,
                                                                CancellationToken cancellationToken)
        {
            if (_authenticatedUserAccessor.AuthenticatedUser.Teams.All(t => t.Id != query.TeamId))
            {
                throw new UserNotAddedToTeamException
                      (
                          _authenticatedUserAccessor.AuthenticatedUser.Id,
                          query.TeamId
                      );
            }

            var totalCount = await _cache.GetOrSetAsync
                             (
                _cacheKey.CountTeamLogs(query.TeamId),
                async() => await _logsCollection.CountAsync(l => l.TeamId == query.TeamId)
                             );

            return(new CountTeamLogsProjection
                   (
                       totalCount
                   ));
        }