Esempio n. 1
0
        public async Task <IActionResult> Get(CancellationToken cancellationToken)
        {
            var query   = new GetAllServersQuery();
            var servers = await Mediator.Send(query, cancellationToken);

            return(new JsonResult(servers));
        }
Esempio n. 2
0
 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));
 }
Esempio n. 3
0
 public async Task <List <ServerDto> > Handle(GetAllServersQuery query)
 {
     return(await _dbContext.Servers.ProjectTo <ServerDto>(_mapper.ConfigurationProvider).ToListAsync());
 }