network-resurrector/NetworkResurrector.Application/Queries/GetToken.cs

41 lines
1008 B
C#

using AutoMapper;
using MediatR;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace NetworkResurrector.Application.Queries
{
public class GetToken
{
public class Query : Query<Model>
{
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<Query, Model>
{
private readonly IMapper _mapper;
public QueryHandler(IMapper mapper)
{
_mapper = mapper;
}
public async Task<Model> Handle(Query request, CancellationToken cancellationToken)
{
return new Model() { Token = Guid.NewGuid(), ValidUntil = DateTime.Now };
}
}
}
}