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

41 lines
1008 B
C#
Raw Normal View History

2020-07-09 02:32:35 +03:00
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)
{
2020-07-09 22:46:52 +03:00
return new Model() { Token = Guid.NewGuid(), ValidUntil = DateTime.Now };
2020-07-09 02:32:35 +03:00
}
}
}
}