Introduce a new `DocumentDetailsDto` record to encapsulate shared document metadata and elements without binary payload. Refactor `DocumentDto` to inherit from `DocumentDetailsDto`, eliminating redundant properties and improving code reuse. Convert `DocumentDto` from a class to a record for immutability. Add a parameterized constructor to `DocumentDto` for initializing binary data alongside metadata. Update `ByteData` to use the `init` accessor. These changes enhance maintainability, reduce duplication, and enforce immutability by leveraging C# records and inheritance.
28 lines
730 B
C#
28 lines
730 B
C#
namespace EnvelopeGenerator.Application.Common.Dto;
|
|
|
|
/// <summary>
|
|
/// Data Transfer Object representing a document within an envelope, including optional binary data and form elements.
|
|
/// </summary>
|
|
public record DocumentDto : DocumentDetailsDto
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public DocumentDto() { }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="byteData"></param>
|
|
/// <param name="details"></param>
|
|
public DocumentDto(byte[] byteData, DocumentDetailsDto details) : base(details)
|
|
{
|
|
ByteData = byteData;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the binary data of the document, if available.
|
|
/// </summary>
|
|
public byte[]? ByteData { get; init; }
|
|
}
|