Exemplo n.º 1
0
        public async Task <ICollection <ActivityStateEntity> > Handle(GetActivityStatesQuery request, CancellationToken cancellationToken)
        {
            string activityHash = request.ActivityId.ComputeHash();
            Guid   agentId      = request.AgentId;

            var query = _context.Documents
                        .AsNoTracking()
                        .OfType <ActivityStateEntity>()
                        .Where(x => x.Activity.Hash == activityHash)
                        .Where(x => x.Agent.AgentId == agentId);

            if (request.Registration.HasValue)
            {
                query.Where(x => x.RegistrationId == request.Registration);
            }

            return(await query.ToListAsync(cancellationToken));
        }
Exemplo n.º 2
0
        public async Task <ICollection <ActivityStateDocument> > Handle(GetActivityStatesQuery request, CancellationToken cancellationToken)
        {
            string activityHash = request.ActivityId.ComputeHash();
            Guid   agentId      = request.AgentId;

            var query = _context.ActivityStates
                        .AsNoTracking()
                        .Where(x => x.Activity.Hash == activityHash)
                        .Where(x => x.Agent.AgentId == agentId);

            if (request.Registration.HasValue)
            {
                query.Where(x => x.Registration == request.Registration);
            }

            var states = await query.ToListAsync(cancellationToken);

            return(_mapper.Map <ICollection <ActivityStateDocument> >(states));
        }