using AutoMapper; using Chatbot.Api.Domain.Repositories; using MediatR; using NDB.Application.DataContracts; using System; using System.Threading; using System.Threading.Tasks; namespace Chatbot.Api.Application.Queries { public class GetBots { public class Query : Query { public Query() { } } public class Model { public Guid BotId { get; set; } public string BotCode { get; set; } public string BotName { get; set; } public DateTime CreationDate { get; set; } } public class QueryHandler : IRequestHandler { private readonly IBotRepository _botRepository; private readonly IMapper _mapper; public QueryHandler(IBotRepository botRepository, IMapper mapper) { _botRepository = botRepository; _mapper = mapper; } public async Task Handle(Query request, CancellationToken cancellationToken) { var bots = await _botRepository.GetBots(); var result = _mapper.Map(bots); return result; } } } }