Example #1
0
            public async Task <CommandResult <FirewallRuleDto> > Handle(Query message, CancellationToken cancellationToken)
            {
                var firewallRule = await _repository.Query()
                                   .Include(f => f.Target)
                                   .FirstOrDefaultAsync(f => f.Id == message.FirwallRuleId);

                return(new CommandResult <FirewallRuleDto>()
                {
                    Result = _mapper.Map <FirewallRuleDto>(firewallRule),
                    IsSucceeded = true
                });
            }
Example #2
0
            public async Task <QueryListResult <FirewallRuleDto> > Handle(Query message, CancellationToken cancellationToken)
            {
                var query = _repository.Query().Where(s => s.TargetId == message.TargetId);

                var firewallRules = await query
                                    .Skip(message.Offset ?? 0)
                                    .Take(message.Limit ?? 20)
                                    .ProjectTo <FirewallRuleDto>(_mapper.ConfigurationProvider)
                                    .ToListAsync(cancellationToken);

                return(new QueryListResult <FirewallRuleDto>()
                {
                    Result = firewallRules,
                    Count = query.Count(),
                    IsSucceeded = true
                });
            }