structure

master
Tudor Stanciu 2020-07-09 02:32:35 +03:00
parent 7e72b40e46
commit 0e28867c19
6 changed files with 87 additions and 8 deletions

View File

@ -4,5 +4,24 @@
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.4" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.5" />
<PackageReference Include="Serilog.AspNetCore" Version="$(SerilogPackageVersion)" />
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsPackageVersion)" />
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="$(SerilogSinksMSSqlServerPackageVersion)" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutoMapperExtensionsPackageVersion)" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="$(MediatRPackageVersion)" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(SwashbucklePackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NetworkResurrector.Application\NetworkResurrector.Application.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -1,8 +0,0 @@
using System;
namespace NetworkResurrector.Application
{
public class Class1
{
}
}

View File

@ -0,0 +1,11 @@
using AutoMapper;
namespace NetworkResurrector.Application.Mappings
{
public class MappingProfile : Profile
{
public MappingProfile()
{
}
}
}

View File

@ -4,4 +4,13 @@
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="$(AutoMapperPackageVersion)" />
<PackageReference Include="MediatR" Version="$(MediatRPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsPackageVersion)" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,42 @@
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)
{
var result = _mapper.Map<Model>(new { Token = Guid.NewGuid(), ValidUntil = DateTime.Now });
return result;
}
}
}
}

View File

@ -0,0 +1,6 @@
using MediatR;
namespace NetworkResurrector.Application.Queries
{
public abstract class Query<TResponse> : IRequest<TResponse>, IBaseRequest { }
}