using AutoMapper; using MediatR; using NDB.Application.DataContracts; using NetworkResurrector.Agent.Domain.Repositories; using System.Threading; using System.Threading.Tasks; namespace NetworkResurrector.Agent.Application.Queries { public class GetMachines { public class Query : Query { public Query() { } } public class Model { public int MachineId { get; set; } public string MachineName { get; set; } public string FullMachineName { get; set; } public string MACAddress { get; set; } public string IPv4Address { get; set; } public string Description { get; set; } } public class QueryHandler : IRequestHandler { private readonly IAgentRepository _repository; private readonly IMapper _mapper; public QueryHandler(IAgentRepository repository, IMapper mapper) { _repository = repository; _mapper = mapper; } public async Task Handle(Query request, CancellationToken cancellationToken) { var bots = await _repository.GetMachines(); var result = _mapper.Map(bots); return result; } } } }