feat(CommandManager): Add ReadDocument command.
This commit is contained in:
parent
975beff416
commit
8785505a91
@ -1,5 +1,4 @@
|
||||
using DigitalData.Core.Abstractions.Infrastructure;
|
||||
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
|
||||
@ -18,8 +18,9 @@
|
||||
<PackageReference Include="DigitalData.Core.Client" Version="2.0.3" />
|
||||
<PackageReference Include="DigitalData.Core.DTO" Version="2.0.1" />
|
||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.0.0" />
|
||||
<PackageReference Include="MediatR" Version="11.1.0" />
|
||||
<PackageReference Include="MediatR" Version="12.5.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.18" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4" />
|
||||
<PackageReference Include="Otp.NET" Version="1.4.0" />
|
||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||
<PackageReference Include="QRCoder-ImageSharp" Version="0.10.0" />
|
||||
|
||||
@ -8,11 +8,21 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using DigitalData.Core.Client;
|
||||
using QRCoder;
|
||||
using EnvelopeGenerator.Application.Contracts.Services;
|
||||
using System.Reflection;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Extensions method for dependency injection
|
||||
/// </summary>
|
||||
public static class DIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds all required services for envelope generator application
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddEnvelopeGeneratorServices(this IServiceCollection services, IConfiguration config)
|
||||
{
|
||||
//Inject CRUD Service and repositoriesad
|
||||
@ -47,6 +57,11 @@ public static class DIExtensions
|
||||
services.TryAddSingleton<IAuthenticator, Authenticator>();
|
||||
services.TryAddSingleton<QRCodeGenerator>();
|
||||
|
||||
services.AddMediatR(cfg =>
|
||||
{
|
||||
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,19 @@
|
||||
using CommandDotNet;
|
||||
using EnvelopeGenerator.Application.Contracts.Services;
|
||||
using EnvelopeGenerator.Application.Documents.Queries.Read;
|
||||
using MediatR;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace EnvelopeGenerator.Terminal;
|
||||
|
||||
public class CommandManager(IEnvelopeReceiverService envelopeReceiverService)
|
||||
public class CommandManager(IEnvelopeReceiverService envelopeReceiverService, IMediator mediator)
|
||||
{
|
||||
private static JsonSerializerOptions Options = new ()
|
||||
{
|
||||
WriteIndented = true // <-- Bu satır okunabilir JSON için önemli
|
||||
};
|
||||
|
||||
[DefaultCommand]
|
||||
public void Execute([Option(Description = "print envelope generator termianal version.")] bool version)
|
||||
{
|
||||
@ -15,4 +23,12 @@ public class CommandManager(IEnvelopeReceiverService envelopeReceiverService)
|
||||
|
||||
[Subcommand]
|
||||
public IEnvelopeReceiverService EnvelopeReceiver => envelopeReceiverService;
|
||||
|
||||
[Command]
|
||||
public async Task ReadDocument(IConsole console, int? id = null, int? envelopeId = null)
|
||||
{
|
||||
ReadDocumentQuery query = new(id, envelopeId);
|
||||
var document = await mediator.Send(query);
|
||||
console.WriteLine(JsonSerializer.Serialize(document, Options));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,6 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PublishAot>true</PublishAot>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user