public async Task <IActionResult> Get(CancellationToken cancellationToken) { var query = new GetAllServersQuery(); var servers = await Mediator.Send(query, cancellationToken); return(new JsonResult(servers)); }
public async Task <IEnumerable <ServerDto> > Handle(GetAllServersQuery request, CancellationToken cancellationToken) { return(await _context.Servers .AsNoTracking() .Select(x => new ServerDto { Id = x.Id, Name = x.Name, Description = x.Description }) .ToListAsync(cancellationToken)); }
public async Task <List <ServerDto> > Handle(GetAllServersQuery query) { return(await _dbContext.Servers.ProjectTo <ServerDto>(_mapper.ConfigurationProvider).ToListAsync()); }