Refactor DTOs for improved structure and documentation
Transitioned from records to classes for flexibility, added XML documentation for clarity, and updated property definitions to use standard getters and setters. Introduced the `required` keyword for essential properties, removed unnecessary constructors, and enhanced property descriptions for better readability. Additionally, overridden `GetHashCode` in `ReceiverReadDto` for proper collection behavior.
This commit is contained in:
@@ -20,7 +20,7 @@ public record ReceiverCreateDto
|
||||
}
|
||||
|
||||
[EmailAddress]
|
||||
public string EmailAddress { get; init; }
|
||||
public required string EmailAddress { get; init; }
|
||||
|
||||
public string? TotpSecretkey { get; init; }
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using DigitalData.Core.Abstractions;
|
||||
using DigitalData.Core.DTO;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Json.Serialization;
|
||||
@@ -7,19 +6,27 @@ using System.Text.Json.Serialization;
|
||||
namespace EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public record ReceiverReadDto(
|
||||
int Id,
|
||||
string EmailAddress,
|
||||
string Signature,
|
||||
DateTime AddedWhen
|
||||
) : BaseDTO<int>(Id), IUnique<int>
|
||||
public class ReceiverReadDto : IUnique<int>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string EmailAddress { get; set; }
|
||||
|
||||
public string Signature { get; set; }
|
||||
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public IEnumerable<EnvelopeReceiverBasicDto>? EnvelopeReceivers { get; init; }
|
||||
public IEnumerable<EnvelopeReceiverBasicDto>? EnvelopeReceivers { get; set; }
|
||||
|
||||
public string? LastUsedName => EnvelopeReceivers?.LastOrDefault()?.Name;
|
||||
|
||||
public string? TotpSecretkey { get; set; } = null;
|
||||
|
||||
public DateTime? TfaRegDeadline { get; set; }
|
||||
};
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id.GetHashCode();
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,26 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object for updating a receiver's information.
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public record ReceiverUpdateDto(int Id, string? TotpSecretkey = null, DateTime? TfaRegDeadline = null) : IUnique<int>;
|
||||
public class ReceiverUpdateDto : IUnique<int>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the receiver.
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the TOTP (Time-based One-Time Password) secret key.
|
||||
/// Optional.
|
||||
/// </summary>
|
||||
public string? TotpSecretkey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the deadline for two-factor authentication registration.
|
||||
/// Optional.
|
||||
/// </summary>
|
||||
public DateTime? TfaRegDeadline { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user