using AutoMapper; using MediatR; using System; using System.Threading; using System.Threading.Tasks; namespace NetworkResurrector.Application.Queries { public class GetToken { public class Query : Query { public string UserName { get; set; } public string Password { get; set; } public Query() { } } public class Model { public Guid Token { get; set; } public DateTime ValidUntil { get; set; } } public class QueryHandler : IRequestHandler { private readonly IMapper _mapper; public QueryHandler(IMapper mapper) { _mapper = mapper; } public async Task Handle(Query request, CancellationToken cancellationToken) { var result = _mapper.Map(new { Token = Guid.NewGuid(), ValidUntil = DateTime.Now }); return result; } } } }