Refactor EnvelopeHistoryDto to use properties

The EnvelopeHistoryDto class has been changed from a record type with positional parameters to a traditional class structure with explicit properties. This refactor improves readability and maintainability, and includes XML documentation for each property. The GetHashCode method has also been overridden to ensure uniqueness based on the Id property.
This commit is contained in:
Developer 02 2025-05-12 16:36:21 +02:00
parent 05867cc645
commit 02aeaea8a9

View File

@ -1,36 +1,73 @@
using DigitalData.Core.Abstractions; using DigitalData.Core.Abstractions;
using DigitalData.Core.DTO;
using DigitalData.UserManager.Application.DTOs.User; using DigitalData.UserManager.Application.DTOs.User;
using EnvelopeGenerator.Application.DTOs.Receiver; using EnvelopeGenerator.Application.DTOs.Receiver;
using Microsoft.AspNetCore.Mvc;
using static EnvelopeGenerator.Common.Constants; using static EnvelopeGenerator.Common.Constants;
namespace EnvelopeGenerator.Application.DTOs.EnvelopeHistory; namespace EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
/// <summary> /// <summary>
/// /// Data Transfer Object representing the history of an envelope, including status, sender, receiver, and related metadata.
/// </summary> /// </summary>
/// <param name="Id"></param> public record EnvelopeHistoryDto : IUnique<long>
/// <param name="EnvelopeId"></param> {
/// <param name="UserReference"></param> /// <summary>
/// <param name="Status"></param> /// Unique identifier for the envelope history entry.
/// <param name="StatusName"></param> /// </summary>
/// <param name="AddedWhen"></param> public long Id { get; set; }
/// <param name="ActionDate"></param>
/// <param name="Sender"></param> /// <summary>
/// <param name="Receiver"></param> /// Identifier of the associated envelope.
/// <param name="ReferenceType"></param> /// </summary>
/// <param name="Comment"></param> public int EnvelopeId { get; set; }
[ApiExplorerSettings(IgnoreApi = true)]
public record EnvelopeHistoryDto( /// <summary>
long Id, /// Reference string for the user related to this history entry.
int EnvelopeId, /// </summary>
string UserReference, public string UserReference { get; set; }
int Status,
string? StatusName, /// <summary>
DateTime AddedWhen, /// Status code of the envelope at this history point.
DateTime? ActionDate, /// </summary>
UserCreateDto? Sender, public int Status { get; set; }
ReceiverReadDto? Receiver,
ReferenceType ReferenceType, /// <summary>
string? Comment = null) : BaseDTO<long>(Id), IUnique<long>; /// Human-readable name of the status.
/// </summary>
public string? StatusName { get; set; }
/// <summary>
/// Date and time when this history entry was added.
/// </summary>
public DateTime AddedWhen { get; set; }
/// <summary>
/// Date and time when an action was performed, if applicable.
/// </summary>
public DateTime? ActionDate { get; set; }
/// <summary>
/// Information about the sender associated with this history entry.
/// </summary>
public UserCreateDto? Sender { get; set; }
/// <summary>
/// Information about the receiver associated with this history entry.
/// </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>
public string? Comment { get; set; }
/// <inheritdoc/>
public override int GetHashCode()
{
return Id.GetHashCode();
}
};