Merge branch 'master' of http://git.dd:3000/AppStd/EnvelopeGenerator
This commit is contained in:
commit
dc42a76f31
@ -1,5 +1,6 @@
|
||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes;
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@ -24,7 +25,7 @@ public record EnvelopeDto
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Status { get; set; }
|
||||
public required EnvelopeStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Default value is string.Empty
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
|
||||
@ -27,7 +27,17 @@ public record EnvelopeHistoryDto
|
||||
/// <summary>
|
||||
/// Include code of the envelope at this history point.
|
||||
/// </summary>
|
||||
public int Status { get; set; }
|
||||
public Constants.EnvelopeStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Type of reference for this history entry.
|
||||
/// </summary>
|
||||
public Constants.ReferenceType ReferenceType => ((int)Status).ToString().FirstOrDefault() switch
|
||||
{
|
||||
'1' => Constants.ReferenceType.Sender,
|
||||
'2' => Constants.ReferenceType.Receiver,
|
||||
_ => Constants.ReferenceType.System,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Human-readable name of the status.
|
||||
@ -54,11 +64,6 @@ public record EnvelopeHistoryDto
|
||||
/// </summary>
|
||||
public ReceiverReadDto? Receiver { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Type of reference for this history entry.
|
||||
/// </summary>
|
||||
public ReferenceType ReferenceType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional comment related to this history entry.
|
||||
/// </summary>
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
<PackageReference Include="DigitalData.Core.Client" Version="2.1.0" />
|
||||
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
|
||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.1.1" />
|
||||
<PackageReference Include="HtmlSanitizer" Version="8.0.865" />
|
||||
<PackageReference Include="MediatR" Version="12.5.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.18" />
|
||||
<PackageReference Include="Otp.NET" Version="1.4.0" />
|
||||
@ -41,7 +42,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EnvelopeGenerator.Domain\EnvelopeGenerator.Domain.csproj" />
|
||||
<ProjectReference Include="..\EnvelopeGenerator.Extensions\EnvelopeGenerator.Extensions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -3,7 +3,7 @@ using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Application.Model;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using System.Text;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Extensions
|
||||
namespace EnvelopeGenerator.Application.Extensions
|
||||
{
|
||||
public static class DecodingExtensions
|
||||
{
|
||||
@ -1,7 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace EnvelopeGenerator.Extensions
|
||||
namespace EnvelopeGenerator.Application.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides extension methods for decoding and extracting information from an envelope receiver ID.
|
||||
@ -1,7 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace EnvelopeGenerator.Extensions
|
||||
namespace EnvelopeGenerator.Application.Extensions
|
||||
{
|
||||
public static class LoggerExtensions
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace EnvelopeGenerator.Extensions;
|
||||
namespace EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
public static class MemoryCacheExtensions
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using OtpNet;
|
||||
|
||||
namespace EnvelopeGenerator.Extensions
|
||||
namespace EnvelopeGenerator.Application.Extensions
|
||||
{
|
||||
public static class StringExtension
|
||||
{
|
||||
@ -33,7 +33,7 @@ public static class TaskExtensions
|
||||
/// <param name="factory">Exception provider</param>
|
||||
/// <returns>The awaited collection if it is not <c>null</c> or empty.</returns>
|
||||
/// <exception cref="NotFoundException">Thrown if the result is <c>null</c> or empty.</exception>
|
||||
public static async Task<IEnumerable<T>> ThrowIfNull<T, TException>(this Task<IEnumerable<T>> task, Func<TException> factory) where TException : Exception
|
||||
public static async Task<IEnumerable<T>> ThrowIfEmpty<T, TException>(this Task<IEnumerable<T>> task, Func<TException> factory) where TException : Exception
|
||||
{
|
||||
var result = await task;
|
||||
return result?.Any() ?? false ? result : throw factory();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System.Text.Encodings.Web;
|
||||
|
||||
namespace EnvelopeGenerator.Extensions
|
||||
namespace EnvelopeGenerator.Application.Extensions
|
||||
{
|
||||
public static class XSSExtensions
|
||||
{
|
||||
@ -1,6 +1,5 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Histories.Commands;
|
||||
using EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Histories;
|
||||
@ -15,7 +14,6 @@ public class MappingProfile: Profile
|
||||
/// </summary>
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<EnvelopeHistory, ReadHistoryResponse>();
|
||||
CreateMap<CreateHistoryCommand, EnvelopeHistory>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumerable<ReadHistoryResponse>>
|
||||
{
|
||||
[Obsolete("Use IRepository")]
|
||||
private readonly IEnvelopeHistoryRepository _repository;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
/// <param name="mapper"></param>
|
||||
[Obsolete("Use IRepository")]
|
||||
public ReadHistoryQueryHandler(IEnvelopeHistoryRepository repository, IMapper mapper)
|
||||
{
|
||||
_repository = repository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotFoundException"></exception>
|
||||
public async Task<IEnumerable<ReadHistoryResponse>> Handle(ReadHistoryQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var hists = await _repository.ReadAsync(request.EnvelopeId, status: request.Status is null ? null : request.Status);
|
||||
|
||||
if (!hists.Any())
|
||||
throw new NotFoundException();
|
||||
|
||||
return _mapper.Map<IEnumerable<ReadHistoryResponse>>(hists);
|
||||
}
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the history of an envelope, including its status, user actions, and references.
|
||||
/// </summary>
|
||||
public class ReadHistoryResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the envelope history record.
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the identifier of the associated envelope.
|
||||
/// </summary>
|
||||
public int EnvelopeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reference identifier of the user who performed the action.
|
||||
/// </summary>
|
||||
public required string UserReference { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status code of the envelope.
|
||||
/// </summary>
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Constants.ReferenceType ReferenceType => Status.ToString().FirstOrDefault() switch
|
||||
{
|
||||
'1' => Constants.ReferenceType.Sender,
|
||||
'2' => Constants.ReferenceType.Receiver,
|
||||
_ => Constants.ReferenceType.System,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the record was added.
|
||||
/// </summary>
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the action occurred.
|
||||
/// </summary>
|
||||
public DateTime? ActionDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional comment about the envelope history record.
|
||||
/// </summary>
|
||||
public string? Comment { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id.GetHashCode();
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using MediatR;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
namespace EnvelopeGenerator.Application.Histories.Queries;
|
||||
|
||||
//TODO: Add sender query
|
||||
/// <summary>
|
||||
@ -15,6 +16,4 @@ public record ReadHistoryQuery(
|
||||
[Required]
|
||||
int EnvelopeId,
|
||||
Constants.EnvelopeStatus? Status = null,
|
||||
bool? OnlyLast = true) : IRequest<IEnumerable<ReadHistoryResponse>>
|
||||
{
|
||||
};
|
||||
bool? OnlyLast = true) : IRequest<IEnumerable<EnvelopeHistoryDto>>;
|
||||
@ -0,0 +1,47 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Histories.Queries;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumerable<EnvelopeHistoryDto>>
|
||||
{
|
||||
private readonly IRepository<EnvelopeHistory> _repo;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="mapper"></param>
|
||||
public ReadHistoryQueryHandler(IRepository<EnvelopeHistory> repo, IMapper mapper)
|
||||
{
|
||||
_repo = repo;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotFoundException"></exception>
|
||||
public async Task<IEnumerable<EnvelopeHistoryDto>> Handle(ReadHistoryQuery request, CancellationToken cancel = default)
|
||||
{
|
||||
var query = _repo.ReadOnly().Where(h => h.EnvelopeId == request.EnvelopeId);
|
||||
if (request.Status is not null)
|
||||
query = query.Where(h => h.Status == request.Status);
|
||||
|
||||
var hists = await query.ToListAsync(cancel);
|
||||
return _mapper.Map<IEnumerable<EnvelopeHistoryDto>>(hists);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Model;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiverReadOnly;
|
||||
using EnvelopeGenerator.Application.Configurations;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
@ -7,7 +7,7 @@ using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using EnvelopeGenerator.Application.Dto.Messaging;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using EnvelopeGenerator.Application.Envelopes;
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Description>Test</Description>
|
||||
<FileVersion>1.0.0.1</FileVersion>
|
||||
<AssemblyVersion>1.0.0.2</AssemblyVersion>
|
||||
<PackageReleaseNotes>Versionshinweis xyz</PackageReleaseNotes>
|
||||
<Version>1.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HtmlSanitizer" Version="8.0.865" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="7.0.19" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Otp.NET" Version="1.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EnvelopeGenerator.Domain\EnvelopeGenerator.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -63,13 +63,13 @@ public class EnvelopeController : ControllerBase
|
||||
public async Task<IActionResult> GetAsync([FromQuery] ReadEnvelopeQuery envelope)
|
||||
{
|
||||
if (User.GetId() is int intId)
|
||||
return await _envelopeService.ReadByUserAsync(intId, min_status: envelope.Status, max_status: envelope.Status).ThenAsync(
|
||||
return await _envelopeService.ReadByUserAsync(intId, min_status: envelope.Status?.Min, max_status: envelope.Status?.Max).ThenAsync(
|
||||
Success: envelopes =>
|
||||
{
|
||||
if (envelope.Id is int id)
|
||||
envelopes = envelopes.Where(e => e.Id == id);
|
||||
|
||||
if (envelope.Status is int status)
|
||||
if (envelope.Status is EnvelopeStatus status)
|
||||
envelopes = envelopes.Where(e => e.Status == status);
|
||||
|
||||
if (envelope.Uuid is string uuid)
|
||||
|
||||
@ -15,6 +15,8 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Data;
|
||||
using System.Reflection.Metadata;
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
|
||||
|
||||
@ -98,11 +100,11 @@ public class EnvelopeReceiverController : ControllerBase
|
||||
|
||||
return await _erService.ReadByUsernameAsync(
|
||||
username: username,
|
||||
min_status: envelopeReceiver.Status?.Min,
|
||||
max_status: envelopeReceiver.Status?.Max,
|
||||
min_status: envelopeReceiver.Envelope.Status?.Min,
|
||||
max_status: envelopeReceiver.Envelope.Status?.Max,
|
||||
envelopeQuery: envelopeReceiver.Envelope,
|
||||
receiverQuery: envelopeReceiver.Receiver,
|
||||
ignore_statuses: envelopeReceiver.Status?.Ignore ?? Array.Empty<int>())
|
||||
ignore_statuses: envelopeReceiver.Envelope.Status?.Ignore ?? Array.Empty<Constants.EnvelopeStatus>())
|
||||
.ThenAsync(
|
||||
Success: Ok,
|
||||
Fail: IActionResult (msg, ntc) =>
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Application.Histories.Queries;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
|
||||
|
||||
@ -17,8 +17,6 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers;
|
||||
[Authorize]
|
||||
public class HistoryController : ControllerBase
|
||||
{
|
||||
private readonly IEnvelopeHistoryService _service;
|
||||
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
private readonly IMediator _mediator;
|
||||
@ -26,12 +24,10 @@ public class HistoryController : ControllerBase
|
||||
/// <summary>
|
||||
/// Konstruktor für den HistoryController.
|
||||
/// </summary>
|
||||
/// <param name="service">Der Dienst, der für die Verarbeitung der Umschlaghistorie verantwortlich ist.</param>
|
||||
/// <param name="memoryCache"></param>
|
||||
/// <param name="mediator"></param>
|
||||
public HistoryController(IEnvelopeHistoryService service, IMemoryCache memoryCache, IMediator mediator)
|
||||
public HistoryController(IMemoryCache memoryCache, IMediator mediator)
|
||||
{
|
||||
_service = service;
|
||||
_memoryCache = memoryCache;
|
||||
_mediator = mediator;
|
||||
}
|
||||
@ -52,9 +48,11 @@ public class HistoryController : ControllerBase
|
||||
/// <response code="200"></response>
|
||||
[HttpGet("related")]
|
||||
[Authorize]
|
||||
public IActionResult GetReferenceTypes(ReferenceType? referenceType = null)
|
||||
public IActionResult GetReferenceTypes(Constants.ReferenceType? referenceType = null)
|
||||
{
|
||||
return referenceType is null ? Ok(_memoryCache.GetEnumAsDictionary<ReferenceType>("gen.api", ReferenceType.Unknown)) : Ok(referenceType.ToString());
|
||||
return referenceType is null
|
||||
? Ok(_memoryCache.GetEnumAsDictionary<Constants.ReferenceType>("gen.api", Constants.ReferenceType.Unknown))
|
||||
: Ok(referenceType.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -93,15 +91,18 @@ public class HistoryController : ControllerBase
|
||||
/// <response code="200"></response>
|
||||
[HttpGet("status")]
|
||||
[Authorize]
|
||||
public IActionResult GetEnvelopeStatus([FromQuery] EnvelopeStatus? status = null)
|
||||
public IActionResult GetEnvelopeStatus([FromQuery] Constants.EnvelopeStatus? status = null)
|
||||
{
|
||||
return status is null ? Ok(_memoryCache.GetEnumAsDictionary<EnvelopeStatus>("gen.api", Status.NonHist, Status.RelatedToFormApp)) : Ok(status.ToString());
|
||||
return status is null
|
||||
? Ok(_memoryCache.GetEnumAsDictionary<Constants.EnvelopeStatus>("gen.api", Constants.Status.NonHist, Constants.Status.RelatedToFormApp))
|
||||
: Ok(status.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ruft die gesamte Umschlaghistorie basierend auf den angegebenen Abfrageparametern ab.
|
||||
/// </summary>
|
||||
/// <param name="historyQuery">Die Abfrageparameter, die die Filterkriterien für die Umschlaghistorie definieren.</param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns>Eine Liste von Historieneinträgen, die den angegebenen Kriterien entsprechen, oder nur der letzte Eintrag.</returns>
|
||||
/// <response code="200">Die Anfrage war erfolgreich, und die Umschlaghistorie wird zurückgegeben.</response>
|
||||
/// <response code="400">Die Anfrage war ungültig oder unvollständig.</response>
|
||||
@ -110,10 +111,9 @@ public class HistoryController : ControllerBase
|
||||
/// <response code="500">Ein unerwarteter Fehler ist aufgetreten.</response>
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> GetAllAsync([FromQuery] ReadHistoryQuery historyQuery)
|
||||
public async Task<IActionResult> GetAllAsync([FromQuery] ReadHistoryQuery historyQuery, CancellationToken cancel)
|
||||
{
|
||||
var history = await _mediator.Send(historyQuery);
|
||||
|
||||
var history = await _mediator.Send(historyQuery, cancel).ThrowIfEmpty(Exceptions.NotFound);
|
||||
return Ok((historyQuery.OnlyLast ?? false) ? history.MaxBy(h => h.AddedWhen) : history);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class CommandManager
|
||||
{
|
||||
ReadDocumentQuery query = new(id, envelopeId);
|
||||
var document = await _mediator.Send(query);
|
||||
console.WriteLine(JsonSerializer.Serialize(save ? document as ReadDocumentResponse : document, Options));
|
||||
console.WriteLine(JsonSerializer.Serialize(document, Options));
|
||||
|
||||
if (save)
|
||||
{
|
||||
|
||||
@ -9,15 +9,11 @@
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
123
EnvelopeGenerator.Tests.Application/HistoryTests.cs
Normal file
123
EnvelopeGenerator.Tests.Application/HistoryTests.cs
Normal file
@ -0,0 +1,123 @@
|
||||
using EnvelopeGenerator.Application;
|
||||
using EnvelopeGenerator.Application.Histories.Commands;
|
||||
using EnvelopeGenerator.Application.Histories.Queries;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Infrastructure;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace EnvelopeGenerator.Tests.Application;
|
||||
|
||||
[TestFixture]
|
||||
public class HistoryTests
|
||||
{
|
||||
private IHost _host;
|
||||
|
||||
private IServiceProvider Provider => _host.Services;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_host = Host.CreateDefaultBuilder()
|
||||
.ConfigureAppConfiguration((context, config) =>
|
||||
{
|
||||
// add appsettings.json
|
||||
config.SetBasePath(Directory.GetCurrentDirectory());
|
||||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
|
||||
})
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
IConfiguration configuration = context.Configuration;
|
||||
|
||||
// add Application and Infrastructure services
|
||||
#pragma warning disable CS0618
|
||||
services.AddEnvelopeGeneratorServices(configuration);
|
||||
services.AddEnvelopeGeneratorInfrastructureServices(
|
||||
(sp, options) => options.UseInMemoryDatabase("EnvelopeGeneratorTestDb"),
|
||||
context.Configuration
|
||||
);
|
||||
#pragma warning restore CS0618
|
||||
})
|
||||
.Build();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
_host.Dispose();
|
||||
}
|
||||
|
||||
private async Task<TResponse> Send<TResponse>(IRequest<TResponse> request)
|
||||
{
|
||||
var mediator = Provider.GetRequiredService<IMediator>();
|
||||
return await mediator.Send(request);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateHistory_And_ReadHistory_Should_Work()
|
||||
{
|
||||
// Arrange
|
||||
var createCmd = new CreateHistoryCommand
|
||||
{
|
||||
EnvelopeId = 1,
|
||||
UserReference = "UserA",
|
||||
Status = Constants.EnvelopeStatus.EnvelopeCreated,
|
||||
Comment = "First create"
|
||||
};
|
||||
|
||||
// Act
|
||||
var id = await Send(createCmd);
|
||||
|
||||
// Assert
|
||||
Assert.That(id, Is.Not.Null);
|
||||
|
||||
// ReadHistory sorgusu
|
||||
var query = new ReadHistoryQuery(1);
|
||||
var result = await Send(query);
|
||||
|
||||
Assert.That(result, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ReadHistory_Should_Filter_By_Status()
|
||||
{
|
||||
// Arrange
|
||||
var createCmd1 = new CreateHistoryCommand
|
||||
{
|
||||
EnvelopeId = 2,
|
||||
UserReference = "UserX",
|
||||
Status = Constants.EnvelopeStatus.EnvelopeCreated
|
||||
};
|
||||
|
||||
var createCmd2 = new CreateHistoryCommand
|
||||
{
|
||||
EnvelopeId = 2,
|
||||
UserReference = "UserX",
|
||||
Status = Constants.EnvelopeStatus.EnvelopePartlySigned
|
||||
};
|
||||
|
||||
await Send(createCmd1);
|
||||
await Send(createCmd2);
|
||||
|
||||
// Act
|
||||
var result = await Send(new ReadHistoryQuery(2, Constants.EnvelopeStatus.EnvelopePartlySigned));
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Has.Exactly(1).Items);
|
||||
Assert.That(result, Has.All.Matches<EnvelopeGenerator.Application.Dto.EnvelopeHistory.EnvelopeHistoryDto>(
|
||||
r => r.Status == Constants.EnvelopeStatus.EnvelopePartlySigned));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ReadHistory_Should_Return_Empty_When_No_Record()
|
||||
{
|
||||
// Act
|
||||
var result = await Send(new ReadHistoryQuery(999));
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.Empty);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"DiPMode": false, //Please be careful when enabling Development in Production (DiP) mode. It allows Swagger and test controllers to be enabled in a production environment.
|
||||
"EnableSwagger": true,
|
||||
"UseDbMigration": false,
|
||||
"EnableTestControllers": true,
|
||||
"DetailedErrors": true,
|
||||
"Logging": {
|
||||
@ -12,7 +13,8 @@
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
|
||||
"Default": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;",
|
||||
"DbMigrationTest": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM_DATA_MIGR_TEST;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
|
||||
},
|
||||
"PSPDFKitLicenseKey": "SXCtGGY9XA-31OGUXQK-r7c6AkdLGPm2ljuyDr1qu0kkhLvydg-Do-fxpNUF4Rq3fS_xAnZRNFRHbXpE6sQ2BMcCSVTcXVJO6tPviexjpiT-HnrDEySlUERJnnvh-tmeOWprxS6BySPnSILkmaVQtUfOIUS-cUbvvEYHTvQBKbSF8di4XHQFyfv49ihr51axm3NVV3AXwh2EiKL5C5XdqBZ4sQ4O7vXBjM2zvxdPxlxdcNYmiU83uAzw7B83O_jubPzya4CdUHh_YH7Nlp2gP56MeG1Sw2JhMtfG3Rj14Sg4ctaeL9p6AEWca5dDjJ2li5tFIV2fQSsw6A_cowLu0gtMm5i8IfJXeIcQbMC2-0wGv1oe9hZYJvFMdzhTM_FiejM0agemxt3lJyzuyP8zbBSOgp7Si6A85krLWPZptyZBTG7pp7IHboUHfPMxCXqi-zMsqewOJtQBE2mjntU-lPryKnssOpMPfswwQX7QSkJYV5EMqNmEhQX6mEkp2wcqFzMC7bJQew1aO4pOpvChUaMvb1vgRek0HxLag0nwQYX2YrYGh7F_xXJs-8HNwJe8H0-eW4x4faayCgM5rB5772CCCsD9ThZcvXFrjNHHLGJ8WuBUFm6LArvSfFQdii_7j-_sqHMpeKZt26NFgivj1A==",
|
||||
"Content-Security-Policy": [ // The first format parameter {0} will be replaced by the nonce value.
|
||||
@ -39,6 +41,11 @@
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"warningLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Warning.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"errorLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
|
||||
@ -50,14 +57,17 @@
|
||||
"maxArchiveDays": 30
|
||||
}
|
||||
},
|
||||
// Trace, Debug, Info, Warn, Error and *Fatal*
|
||||
"rules": [
|
||||
{
|
||||
"logger": "*",
|
||||
"minLevel": "Info",
|
||||
"maxLevel": "Warn",
|
||||
"level": "Info",
|
||||
"writeTo": "infoLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Warn",
|
||||
"writeTo": "warningLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Error",
|
||||
@ -140,17 +150,33 @@
|
||||
}
|
||||
},
|
||||
"TFARegParams": {
|
||||
"TimeLimit": "00:30:00"
|
||||
"TimeLimit": "90.00:00:00"
|
||||
},
|
||||
"DbTriggerParams": {
|
||||
"Envelope": [ "TBSIG_ENVELOPE_HISTORY_AFT_INS" ],
|
||||
"EnvelopeHistory": [ "TBSIG_ENVELOPE_HISTORY_AFT_INS" ],
|
||||
"EmailOut": [ "TBEMLP_EMAIL_OUT_AFT_INS", "TBEMLP_EMAIL_OUT_AFT_UPD" ],
|
||||
"EnvelopeReceiverReadOnly": [ "TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD" ],
|
||||
"Receiver": []
|
||||
"Receiver": [],
|
||||
"EmailTemplate": [ "TBSIG_EMAIL_TEMPLATE_AFT_UPD" ]
|
||||
},
|
||||
"MainPageTitle": null,
|
||||
"AnnotationParams": {
|
||||
"Background": {
|
||||
"Margin": 0.20,
|
||||
"BackgroundColor": {
|
||||
"R": 222,
|
||||
"G": 220,
|
||||
"B": 215
|
||||
},
|
||||
"BorderColor": {
|
||||
"R": 204,
|
||||
"G": 202,
|
||||
"B": 198
|
||||
},
|
||||
"BorderStyle": "underline",
|
||||
"BorderWidth": 4
|
||||
},
|
||||
"DefaultAnnotation": {
|
||||
"Width": 1,
|
||||
"Height": 0.5,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using EnvelopeGenerator.CommonServices;
|
||||
using EnvelopeGenerator.Web.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
@ -3,7 +3,7 @@ using EnvelopeGenerator.Web.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Encodings.Web;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
@ -6,7 +6,7 @@ using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using EnvelopeGenerator.Application.Resources;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using EnvelopeGenerator.Web.Extensions;
|
||||
using EnvelopeGenerator.Web.Models;
|
||||
using Ganss.Xss;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using EnvelopeGenerator.Web.Models;
|
||||
using Ganss.Xss;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using EnvelopeGenerator.Application.Resources;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using DigitalData.Core.API;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
@ -27,7 +27,7 @@ public class TestEnvelopeReceiverController : ControllerBase
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get([FromQuery] ReadEnvelopeReceiverQuery q, CancellationToken cancel)
|
||||
=> Ok(await _mediator.Send(q, cancel).ThrowIfNull(Exceptions.NotFound));
|
||||
=> Ok(await _mediator.Send(q, cancel).ThrowIfEmpty(Exceptions.NotFound));
|
||||
|
||||
[Obsolete("Use MediatR")]
|
||||
[HttpGet("verify-access-code/{envelope_receiver_id}")]
|
||||
|
||||
@ -2136,7 +2136,6 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EnvelopeGenerator.Application\EnvelopeGenerator.Application.csproj" />
|
||||
<ProjectReference Include="..\EnvelopeGenerator.CommonServices\EnvelopeGenerator.CommonServices.vbproj" />
|
||||
<ProjectReference Include="..\EnvelopeGenerator.Extensions\EnvelopeGenerator.Extensions.csproj" />
|
||||
<ProjectReference Include="..\EnvelopeGenerator.Infrastructure\EnvelopeGenerator.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
@using EnvelopeGenerator.Web
|
||||
@using EnvelopeGenerator.Web.Models
|
||||
@using EnvelopeGenerator.Web.Sanitizers
|
||||
@using EnvelopeGenerator.Extensions
|
||||
@using EnvelopeGenerator.Application.Extensions
|
||||
@using Microsoft.Extensions.Localization
|
||||
@using EnvelopeGenerator.Application.Resources
|
||||
@using Microsoft.Extensions.Options
|
||||
|
||||
@ -21,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnvelopeGenerator.Applicati
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnvelopeGenerator.GeneratorAPI", "EnvelopeGenerator.GeneratorAPI\EnvelopeGenerator.GeneratorAPI.csproj", "{E5E12BA4-60C1-48BA-9053-0F8B62B38124}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnvelopeGenerator.Extensions", "EnvelopeGenerator.Extensions\EnvelopeGenerator.Extensions.csproj", "{47F98812-4280-4D53-B04A-2AAEEA5EBC31}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{9943209E-1744-4944-B1BA-4F87FC1A0EEB}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{134D4164-B291-4E19-99B9-E4FA3AFAB62C}"
|
||||
@ -79,10 +77,6 @@ Global
|
||||
{E5E12BA4-60C1-48BA-9053-0F8B62B38124}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E5E12BA4-60C1-48BA-9053-0F8B62B38124}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E5E12BA4-60C1-48BA-9053-0F8B62B38124}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||
{47F98812-4280-4D53-B04A-2AAEEA5EBC31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{47F98812-4280-4D53-B04A-2AAEEA5EBC31}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{47F98812-4280-4D53-B04A-2AAEEA5EBC31}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{47F98812-4280-4D53-B04A-2AAEEA5EBC31}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A4D0DD1A-67BC-4E1A-AD29-BC4BC0D41399}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A4D0DD1A-67BC-4E1A-AD29-BC4BC0D41399}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A4D0DD1A-67BC-4E1A-AD29-BC4BC0D41399}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -105,7 +99,6 @@ Global
|
||||
{63E32615-0ECA-42DC-96E3-91037324B7C7} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{5A9984F8-51A2-4558-A415-EC5FEED7CF7D} = {9943209E-1744-4944-B1BA-4F87FC1A0EEB}
|
||||
{E5E12BA4-60C1-48BA-9053-0F8B62B38124} = {E3C758DC-914D-4B7E-8457-0813F1FDB0CB}
|
||||
{47F98812-4280-4D53-B04A-2AAEEA5EBC31} = {9943209E-1744-4944-B1BA-4F87FC1A0EEB}
|
||||
{9943209E-1744-4944-B1BA-4F87FC1A0EEB} = {134D4164-B291-4E19-99B9-E4FA3AFAB62C}
|
||||
{A4D0DD1A-67BC-4E1A-AD29-BC4BC0D41399} = {0CBC2432-A561-4440-89BC-671B66A24146}
|
||||
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {134D4164-B291-4E19-99B9-E4FA3AFAB62C}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user