Remove IDocument interface and related dependencies
Decoupled `Document` and `DocumentDetailsDto` from the `IDocument` interface by removing its implementation. Eliminated the `ElementsBase` property from both classes as it was tied to the interface. Simplified the `FinalizeEnvelopeCommandHandler` constructor by removing the unused `HistoryRepo` parameter. Deleted the `IDocument` interface and its extension methods, including `IsSigned`, to reduce unnecessary abstractions and improve code maintainability.
This commit is contained in:
@@ -5,7 +5,7 @@ namespace EnvelopeGenerator.Application.Common.Dto;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Data Transfer Object representing document metadata and elements without binary payload.
|
/// Data Transfer Object representing document metadata and elements without binary payload.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public record DocumentDetailsDto : IDocument
|
public record DocumentDetailsDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the unique identifier of the document.
|
/// Gets or sets the unique identifier of the document.
|
||||||
@@ -26,9 +26,4 @@ public record DocumentDetailsDto : IDocument
|
|||||||
/// Gets or sets the collection of elements associated with the document for receiver interactions, if any.
|
/// Gets or sets the collection of elements associated with the document for receiver interactions, if any.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<DocReceiverElementDto>? Elements { get; init; }
|
public IEnumerable<DocReceiverElementDto>? Elements { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<IDocReceiverElement>? ElementsBase => Elements;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ public record FinalizeEnvelopeCommand : EnvelopeQueryBase, IRequest
|
|||||||
/// <param name="Repo"></param>
|
/// <param name="Repo"></param>
|
||||||
/// <param name="Sender"></param>
|
/// <param name="Sender"></param>
|
||||||
/// <param name="NtfServer"></param>
|
/// <param name="NtfServer"></param>
|
||||||
public class FinalizeEnvelopeCommandHandler(IRepository<Envelope> Repo, ISender Sender, IEnvelopeNotificationService NtfServer, ILogger<FinalizeEnvelopeCommandHandler> Logger, IRepository<History> HistoryRepo) : IRequestHandler<FinalizeEnvelopeCommand>
|
/// <param name="Logger"></param>
|
||||||
|
public class FinalizeEnvelopeCommandHandler(IRepository<Envelope> Repo, ISender Sender, IEnvelopeNotificationService NtfServer, ILogger<FinalizeEnvelopeCommandHandler> Logger) : IRequestHandler<FinalizeEnvelopeCommand>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using System.Linq;
|
|||||||
namespace EnvelopeGenerator.Domain.Entities
|
namespace EnvelopeGenerator.Domain.Entities
|
||||||
{
|
{
|
||||||
[Table("TBSIG_ENVELOPE_DOCUMENT", Schema = "dbo")]
|
[Table("TBSIG_ENVELOPE_DOCUMENT", Schema = "dbo")]
|
||||||
public class Document : IDocument, IHasEnvelope, IHasAddedWhen
|
public class Document : IHasEnvelope, IHasAddedWhen
|
||||||
{
|
{
|
||||||
public Document()
|
public Document()
|
||||||
{
|
{
|
||||||
@@ -66,12 +66,6 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
#endif
|
#endif
|
||||||
Elements { get; set; }
|
Elements { get; set; }
|
||||||
|
|
||||||
public IEnumerable<IDocReceiverElement>
|
|
||||||
#if nullable
|
|
||||||
?
|
|
||||||
#endif
|
|
||||||
ElementsBase => Elements;
|
|
||||||
|
|
||||||
[ForeignKey("EnvelopeId")]
|
[ForeignKey("EnvelopeId")]
|
||||||
public virtual Envelope
|
public virtual Envelope
|
||||||
#if nullable
|
#if nullable
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Domain.Interfaces
|
|
||||||
{
|
|
||||||
public interface IDocument
|
|
||||||
{
|
|
||||||
IEnumerable<IDocReceiverElement>
|
|
||||||
#if nullable
|
|
||||||
?
|
|
||||||
#endif
|
|
||||||
ElementsBase { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DocumentExtensions
|
|
||||||
{
|
|
||||||
public static bool IsSigned<TElement, TElements>(this IDocument document)
|
|
||||||
{
|
|
||||||
if(document.ElementsBase == null)
|
|
||||||
throw new ArgumentNullException(nameof(document.ElementsBase), "Elements collection cannot be null. Please add with Includ()");
|
|
||||||
|
|
||||||
foreach (var element in document.ElementsBase)
|
|
||||||
if (!element.IsSigned())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user