diff --git a/EnvelopeGenerator.Application/Dto/EnvelopeDto.cs b/EnvelopeGenerator.Application/Dto/EnvelopeDto.cs
index 8b335f99..81679f02 100644
--- a/EnvelopeGenerator.Application/Dto/EnvelopeDto.cs
+++ b/EnvelopeGenerator.Application/Dto/EnvelopeDto.cs
@@ -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
///
///
///
- public int Status { get; set; }
+ public required EnvelopeStatus Status { get; set; }
///
/// Default value is string.Empty
diff --git a/EnvelopeGenerator.Application/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs b/EnvelopeGenerator.Application/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs
index 53bb2488..7ae0163a 100644
--- a/EnvelopeGenerator.Application/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs
+++ b/EnvelopeGenerator.Application/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs
@@ -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
///
/// Include code of the envelope at this history point.
///
- public int Status { get; set; }
+ public Constants.EnvelopeStatus Status { get; set; }
+
+ ///
+ /// Type of reference for this history entry.
+ ///
+ public Constants.ReferenceType ReferenceType => ((int)Status).ToString().FirstOrDefault() switch
+ {
+ '1' => Constants.ReferenceType.Sender,
+ '2' => Constants.ReferenceType.Receiver,
+ _ => Constants.ReferenceType.System,
+ };
///
/// Human-readable name of the status.
@@ -54,11 +64,6 @@ public record EnvelopeHistoryDto
///
public ReceiverReadDto? Receiver { get; set; }
- ///
- /// Type of reference for this history entry.
- ///
- public ReferenceType ReferenceType { get; set; }
-
///
/// Optional comment related to this history entry.
///
diff --git a/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj b/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj
index abeab90e..27b74ee1 100644
--- a/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj
+++ b/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj
@@ -19,6 +19,7 @@
+
@@ -41,7 +42,6 @@
-
diff --git a/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReceiverAlreadySignedQuery.cs b/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReceiverAlreadySignedQuery.cs
index 6e71bbc3..8279b81c 100644
--- a/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReceiverAlreadySignedQuery.cs
+++ b/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReceiverAlreadySignedQuery.cs
@@ -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;
diff --git a/EnvelopeGenerator.Extensions/DecodingExtensions.cs b/EnvelopeGenerator.Application/Extensions/DecodingExtensions.cs
similarity index 99%
rename from EnvelopeGenerator.Extensions/DecodingExtensions.cs
rename to EnvelopeGenerator.Application/Extensions/DecodingExtensions.cs
index ad5e6800..0f43df21 100644
--- a/EnvelopeGenerator.Extensions/DecodingExtensions.cs
+++ b/EnvelopeGenerator.Application/Extensions/DecodingExtensions.cs
@@ -1,7 +1,7 @@
using System.Text;
using static EnvelopeGenerator.Domain.Constants;
-namespace EnvelopeGenerator.Extensions
+namespace EnvelopeGenerator.Application.Extensions
{
public static class DecodingExtensions
{
diff --git a/EnvelopeGenerator.Extensions/EncodingExtensions.cs b/EnvelopeGenerator.Application/Extensions/EncodingExtensions.cs
similarity index 95%
rename from EnvelopeGenerator.Extensions/EncodingExtensions.cs
rename to EnvelopeGenerator.Application/Extensions/EncodingExtensions.cs
index e1acf0e9..0534cfd3 100644
--- a/EnvelopeGenerator.Extensions/EncodingExtensions.cs
+++ b/EnvelopeGenerator.Application/Extensions/EncodingExtensions.cs
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging;
using System.Text;
-namespace EnvelopeGenerator.Extensions
+namespace EnvelopeGenerator.Application.Extensions
{
///
/// Provides extension methods for decoding and extracting information from an envelope receiver ID.
diff --git a/EnvelopeGenerator.Extensions/LoggerExtensions.cs b/EnvelopeGenerator.Application/Extensions/LoggerExtensions.cs
similarity index 96%
rename from EnvelopeGenerator.Extensions/LoggerExtensions.cs
rename to EnvelopeGenerator.Application/Extensions/LoggerExtensions.cs
index b1c56974..f37cb7dd 100644
--- a/EnvelopeGenerator.Extensions/LoggerExtensions.cs
+++ b/EnvelopeGenerator.Application/Extensions/LoggerExtensions.cs
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging;
using System.Text;
-namespace EnvelopeGenerator.Extensions
+namespace EnvelopeGenerator.Application.Extensions
{
public static class LoggerExtensions
{
diff --git a/EnvelopeGenerator.Extensions/MemoryCacheExtensions.cs b/EnvelopeGenerator.Application/Extensions/MemoryCacheExtensions.cs
similarity index 95%
rename from EnvelopeGenerator.Extensions/MemoryCacheExtensions.cs
rename to EnvelopeGenerator.Application/Extensions/MemoryCacheExtensions.cs
index f9b0a1ac..97932921 100644
--- a/EnvelopeGenerator.Extensions/MemoryCacheExtensions.cs
+++ b/EnvelopeGenerator.Application/Extensions/MemoryCacheExtensions.cs
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Caching.Memory;
-namespace EnvelopeGenerator.Extensions;
+namespace EnvelopeGenerator.Application.Extensions;
public static class MemoryCacheExtensions
{
diff --git a/EnvelopeGenerator.Extensions/StringExtension.cs b/EnvelopeGenerator.Application/Extensions/StringExtension.cs
similarity index 88%
rename from EnvelopeGenerator.Extensions/StringExtension.cs
rename to EnvelopeGenerator.Application/Extensions/StringExtension.cs
index b08a0f66..8df916f7 100644
--- a/EnvelopeGenerator.Extensions/StringExtension.cs
+++ b/EnvelopeGenerator.Application/Extensions/StringExtension.cs
@@ -1,6 +1,6 @@
using OtpNet;
-namespace EnvelopeGenerator.Extensions
+namespace EnvelopeGenerator.Application.Extensions
{
public static class StringExtension
{
diff --git a/EnvelopeGenerator.Application/Extensions/TaskExtensions.cs b/EnvelopeGenerator.Application/Extensions/TaskExtensions.cs
index 8f598e52..01ad829a 100644
--- a/EnvelopeGenerator.Application/Extensions/TaskExtensions.cs
+++ b/EnvelopeGenerator.Application/Extensions/TaskExtensions.cs
@@ -33,7 +33,7 @@ public static class TaskExtensions
/// Exception provider
/// The awaited collection if it is not null or empty.
/// Thrown if the result is null or empty.
- public static async Task> ThrowIfNull(this Task> task, Func factory) where TException : Exception
+ public static async Task> ThrowIfEmpty(this Task> task, Func factory) where TException : Exception
{
var result = await task;
return result?.Any() ?? false ? result : throw factory();
diff --git a/EnvelopeGenerator.Extensions/XSSExtensions.cs b/EnvelopeGenerator.Application/Extensions/XSSExtensions.cs
similarity index 93%
rename from EnvelopeGenerator.Extensions/XSSExtensions.cs
rename to EnvelopeGenerator.Application/Extensions/XSSExtensions.cs
index 3649df9d..2c5dac80 100644
--- a/EnvelopeGenerator.Extensions/XSSExtensions.cs
+++ b/EnvelopeGenerator.Application/Extensions/XSSExtensions.cs
@@ -2,7 +2,7 @@
using Microsoft.Extensions.Localization;
using System.Text.Encodings.Web;
-namespace EnvelopeGenerator.Extensions
+namespace EnvelopeGenerator.Application.Extensions
{
public static class XSSExtensions
{
diff --git a/EnvelopeGenerator.Application/Histories/MappingProfile.cs b/EnvelopeGenerator.Application/Histories/MappingProfile.cs
index 8ce5c5bc..cbd8b3bd 100644
--- a/EnvelopeGenerator.Application/Histories/MappingProfile.cs
+++ b/EnvelopeGenerator.Application/Histories/MappingProfile.cs
@@ -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
///
public MappingProfile()
{
- CreateMap();
CreateMap();
}
}
diff --git a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQueryHandler.cs b/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQueryHandler.cs
deleted file mode 100644
index ddc88001..00000000
--- a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQueryHandler.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using AutoMapper;
-using EnvelopeGenerator.Application.Interfaces.Repositories;
-using DigitalData.Core.Exceptions;
-using MediatR;
-
-namespace EnvelopeGenerator.Application.Histories.Queries.Read;
-
-///
-///
-///
-public class ReadHistoryQueryHandler : IRequestHandler>
-{
- [Obsolete("Use IRepository")]
- private readonly IEnvelopeHistoryRepository _repository;
-
- private readonly IMapper _mapper;
-
- ///
- ///
- ///
- ///
- ///
- [Obsolete("Use IRepository")]
- public ReadHistoryQueryHandler(IEnvelopeHistoryRepository repository, IMapper mapper)
- {
- _repository = repository;
- _mapper = mapper;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task> 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>(hists);
- }
-}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryResponse.cs b/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryResponse.cs
deleted file mode 100644
index 7957839b..00000000
--- a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryResponse.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using EnvelopeGenerator.Domain;
-
-namespace EnvelopeGenerator.Application.Histories.Queries.Read;
-
-///
-/// Represents the history of an envelope, including its status, user actions, and references.
-///
-public class ReadHistoryResponse
-{
- ///
- /// Gets or sets the unique identifier of the envelope history record.
- ///
- public long Id { get; set; }
-
- ///
- /// Gets or sets the identifier of the associated envelope.
- ///
- public int EnvelopeId { get; set; }
-
- ///
- /// Gets or sets the reference identifier of the user who performed the action.
- ///
- public required string UserReference { get; set; }
-
- ///
- /// Gets or sets the status code of the envelope.
- ///
- public int Status { get; set; }
-
- ///
- ///
- ///
- public Constants.ReferenceType ReferenceType => Status.ToString().FirstOrDefault() switch
- {
- '1' => Constants.ReferenceType.Sender,
- '2' => Constants.ReferenceType.Receiver,
- _ => Constants.ReferenceType.System,
- };
-
- ///
- /// Gets or sets the date and time when the record was added.
- ///
- public DateTime AddedWhen { get; set; }
-
- ///
- /// Gets or sets the date and time when the action occurred.
- ///
- public DateTime? ActionDate { get; set; }
-
- ///
- /// Gets or sets the optional comment about the envelope history record.
- ///
- public string? Comment { get; set; }
-
- ///
- public override int GetHashCode()
- {
- return Id.GetHashCode();
- }
-}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQuery.cs b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs
similarity index 74%
rename from EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQuery.cs
rename to EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs
index 57dc8f88..27490d43 100644
--- a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQuery.cs
+++ b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs
@@ -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
///
@@ -15,6 +16,4 @@ public record ReadHistoryQuery(
[Required]
int EnvelopeId,
Constants.EnvelopeStatus? Status = null,
- bool? OnlyLast = true) : IRequest>
-{
-};
\ No newline at end of file
+ bool? OnlyLast = true) : IRequest>;
\ No newline at end of file
diff --git a/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQueryHandler.cs b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQueryHandler.cs
new file mode 100644
index 00000000..ba558303
--- /dev/null
+++ b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQueryHandler.cs
@@ -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;
+
+///
+///
+///
+public class ReadHistoryQueryHandler : IRequestHandler>
+{
+ private readonly IRepository _repo;
+
+ private readonly IMapper _mapper;
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public ReadHistoryQueryHandler(IRepository repo, IMapper mapper)
+ {
+ _repo = repo;
+ _mapper = mapper;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task> 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>(hists);
+ }
+}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Application/Model/EnvelopeReceiverQueryBase.cs b/EnvelopeGenerator.Application/Model/EnvelopeReceiverQueryBase.cs
index 6b00e9a1..d370b8cb 100644
--- a/EnvelopeGenerator.Application/Model/EnvelopeReceiverQueryBase.cs
+++ b/EnvelopeGenerator.Application/Model/EnvelopeReceiverQueryBase.cs
@@ -1,5 +1,5 @@
using DigitalData.Core.Exceptions;
-using EnvelopeGenerator.Extensions;
+using EnvelopeGenerator.Application.Extensions;
namespace EnvelopeGenerator.Application.Model;
diff --git a/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs b/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs
index ed672d0c..54264b9f 100644
--- a/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs
+++ b/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs
@@ -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;
diff --git a/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs b/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs
index c845dec6..b73337cd 100644
--- a/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs
+++ b/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs
@@ -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;
diff --git a/EnvelopeGenerator.Extensions/EnvelopeGenerator.Extensions.csproj b/EnvelopeGenerator.Extensions/EnvelopeGenerator.Extensions.csproj
deleted file mode 100644
index 5a855b8e..00000000
--- a/EnvelopeGenerator.Extensions/EnvelopeGenerator.Extensions.csproj
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
- net7.0
- enable
- enable
- Test
- 1.0.0.1
- 1.0.0.2
- Versionshinweis xyz
- 1.1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeController.cs
index 6af393ce..d5cd2e42 100644
--- a/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeController.cs
+++ b/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeController.cs
@@ -63,13 +63,13 @@ public class EnvelopeController : ControllerBase
public async Task 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)
diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeReceiverController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeReceiverController.cs
index f46eabca..cbe3aa2c 100644
--- a/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeReceiverController.cs
+++ b/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeReceiverController.cs
@@ -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())
+ ignore_statuses: envelopeReceiver.Envelope.Status?.Ignore ?? Array.Empty())
.ThenAsync(
Success: Ok,
Fail: IActionResult (msg, ntc) =>
diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs
index cd594ddc..e45a183d 100644
--- a/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs
+++ b/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs
@@ -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
///
/// Konstruktor für den HistoryController.
///
- /// Der Dienst, der für die Verarbeitung der Umschlaghistorie verantwortlich ist.
///
///
- 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
///
[HttpGet("related")]
[Authorize]
- public IActionResult GetReferenceTypes(ReferenceType? referenceType = null)
+ public IActionResult GetReferenceTypes(Constants.ReferenceType? referenceType = null)
{
- return referenceType is null ? Ok(_memoryCache.GetEnumAsDictionary("gen.api", ReferenceType.Unknown)) : Ok(referenceType.ToString());
+ return referenceType is null
+ ? Ok(_memoryCache.GetEnumAsDictionary("gen.api", Constants.ReferenceType.Unknown))
+ : Ok(referenceType.ToString());
}
///
@@ -93,15 +91,18 @@ public class HistoryController : ControllerBase
///
[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("gen.api", Status.NonHist, Status.RelatedToFormApp)) : Ok(status.ToString());
+ return status is null
+ ? Ok(_memoryCache.GetEnumAsDictionary("gen.api", Constants.Status.NonHist, Constants.Status.RelatedToFormApp))
+ : Ok(status.ToString());
}
///
/// Ruft die gesamte Umschlaghistorie basierend auf den angegebenen Abfrageparametern ab.
///
/// Die Abfrageparameter, die die Filterkriterien für die Umschlaghistorie definieren.
+ ///
/// Eine Liste von Historieneinträgen, die den angegebenen Kriterien entsprechen, oder nur der letzte Eintrag.
/// Die Anfrage war erfolgreich, und die Umschlaghistorie wird zurückgegeben.
/// Die Anfrage war ungültig oder unvollständig.
@@ -110,10 +111,9 @@ public class HistoryController : ControllerBase
/// Ein unerwarteter Fehler ist aufgetreten.
[HttpGet]
[Authorize]
- public async Task GetAllAsync([FromQuery] ReadHistoryQuery historyQuery)
+ public async Task 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);
}
}
diff --git a/EnvelopeGenerator.Terminal/CommandManager.cs b/EnvelopeGenerator.Terminal/CommandManager.cs
index fb9bfc7a..40ae8e61 100644
--- a/EnvelopeGenerator.Terminal/CommandManager.cs
+++ b/EnvelopeGenerator.Terminal/CommandManager.cs
@@ -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)
{
diff --git a/EnvelopeGenerator.Tests.Application/EnvelopeGenerator.Tests.Application.csproj b/EnvelopeGenerator.Tests.Application/EnvelopeGenerator.Tests.Application.csproj
index cfe0e635..1ec5a917 100644
--- a/EnvelopeGenerator.Tests.Application/EnvelopeGenerator.Tests.Application.csproj
+++ b/EnvelopeGenerator.Tests.Application/EnvelopeGenerator.Tests.Application.csproj
@@ -9,15 +9,11 @@
true
-
-
-
-
- PreserveNewest
true
PreserveNewest
+ PreserveNewest
diff --git a/EnvelopeGenerator.Tests.Application/HistoryTests.cs b/EnvelopeGenerator.Tests.Application/HistoryTests.cs
new file mode 100644
index 00000000..da06e020
--- /dev/null
+++ b/EnvelopeGenerator.Tests.Application/HistoryTests.cs
@@ -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 Send(IRequest request)
+ {
+ var mediator = Provider.GetRequiredService();
+ 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(
+ 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);
+ }
+}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Tests.Application/appsettings.json b/EnvelopeGenerator.Tests.Application/appsettings.json
index 136c48a8..6c26db74 100644
--- a/EnvelopeGenerator.Tests.Application/appsettings.json
+++ b/EnvelopeGenerator.Tests.Application/appsettings.json
@@ -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,
diff --git a/EnvelopeGenerator.Web/Controllers/DocumentController.cs b/EnvelopeGenerator.Web/Controllers/DocumentController.cs
index 619b6cbb..a0621ac2 100644
--- a/EnvelopeGenerator.Web/Controllers/DocumentController.cs
+++ b/EnvelopeGenerator.Web/Controllers/DocumentController.cs
@@ -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;
diff --git a/EnvelopeGenerator.Web/Controllers/EnvelopeController.cs b/EnvelopeGenerator.Web/Controllers/EnvelopeController.cs
index f3438a11..6f0ade63 100644
--- a/EnvelopeGenerator.Web/Controllers/EnvelopeController.cs
+++ b/EnvelopeGenerator.Web/Controllers/EnvelopeController.cs
@@ -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;
diff --git a/EnvelopeGenerator.Web/Controllers/HomeController.cs b/EnvelopeGenerator.Web/Controllers/HomeController.cs
index 4c306dcc..313f1379 100644
--- a/EnvelopeGenerator.Web/Controllers/HomeController.cs
+++ b/EnvelopeGenerator.Web/Controllers/HomeController.cs
@@ -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;
diff --git a/EnvelopeGenerator.Web/Controllers/TFARegController.cs b/EnvelopeGenerator.Web/Controllers/TFARegController.cs
index fb470df9..9225acf9 100644
--- a/EnvelopeGenerator.Web/Controllers/TFARegController.cs
+++ b/EnvelopeGenerator.Web/Controllers/TFARegController.cs
@@ -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;
diff --git a/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeController.cs b/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeController.cs
index d6533ec7..c820386d 100644
--- a/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeController.cs
+++ b/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeController.cs
@@ -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;
diff --git a/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeReceiverController.cs b/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeReceiverController.cs
index c6a93bec..ba8a0569 100644
--- a/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeReceiverController.cs
+++ b/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeReceiverController.cs
@@ -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 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}")]
diff --git a/EnvelopeGenerator.Web/EnvelopeGenerator.Web.csproj b/EnvelopeGenerator.Web/EnvelopeGenerator.Web.csproj
index 51a822fb..2bca6c19 100644
--- a/EnvelopeGenerator.Web/EnvelopeGenerator.Web.csproj
+++ b/EnvelopeGenerator.Web/EnvelopeGenerator.Web.csproj
@@ -2136,7 +2136,6 @@
-
diff --git a/EnvelopeGenerator.Web/Views/_ViewImports.cshtml b/EnvelopeGenerator.Web/Views/_ViewImports.cshtml
index d35750f9..63b28eb0 100644
--- a/EnvelopeGenerator.Web/Views/_ViewImports.cshtml
+++ b/EnvelopeGenerator.Web/Views/_ViewImports.cshtml
@@ -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
diff --git a/EnvelopeGenerator.sln b/EnvelopeGenerator.sln
index eb3d69e9..8b041a64 100644
--- a/EnvelopeGenerator.sln
+++ b/EnvelopeGenerator.sln
@@ -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}