feat(ModifyDocStatusCommandBase): create abstract class to handle common properties of commands
This commit is contained in:
parent
811656c4ca
commit
996b544633
@ -1,19 +1,17 @@
|
|||||||
using EnvelopeGenerator.Domain;
|
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CreateDocStatusCommand : UpdateDocStatusCommand
|
public record CreateDocStatusCommand : ModifyDocStatusCommandBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets timestamp when this record was added. Returns the current date and time.
|
/// Gets timestamp when this record was added. Returns null.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime AddedWhen => StatusChangedWhen;
|
public override DateTime? ChangedWhen => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets timestamp when this record was added. Returns the current date and time.
|
/// Gets timestamp when this record was added. Returns the StatusChangedWhen value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override DateTime? ChangedWhen { get; } = null;
|
public DateTime AddedWhen => StatusChangedWhen;
|
||||||
}
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
using EnvelopeGenerator.Domain;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public abstract record ModifyDocStatusCommandBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ID of the associated envelope.
|
||||||
|
/// </summary>
|
||||||
|
public int EnvelopeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ID of the receiver associated with this status.
|
||||||
|
/// </summary>
|
||||||
|
public int ReceiverId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current status code.
|
||||||
|
/// </summary>
|
||||||
|
public Constants.DocumentStatus Status => Value is null ? Constants.DocumentStatus.Created : Constants.DocumentStatus.Signed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the display value associated with the status.
|
||||||
|
/// </summary>
|
||||||
|
public string? Value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets timestamp when this record was added.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime StatusChangedWhen { get; } = DateTime.Now;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets timestamp when this record was added.
|
||||||
|
/// </summary>
|
||||||
|
public abstract DateTime? ChangedWhen { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Maps the current command to a new instance of the specified type.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDest"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public TDest To<TDest>() where TDest : ModifyDocStatusCommandBase, new()
|
||||||
|
=> new()
|
||||||
|
{
|
||||||
|
EnvelopeId = EnvelopeId,
|
||||||
|
ReceiverId = ReceiverId,
|
||||||
|
Value = Value
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -5,35 +5,10 @@ namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UpdateDocStatusCommand
|
public record UpdateDocStatusCommand : ModifyDocStatusCommandBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the ID of the associated envelope.
|
/// Gets timestamp when this record was added. Returns the StatusChangedWhen value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int EnvelopeId { get; set; }
|
public override DateTime? ChangedWhen => StatusChangedWhen;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the ID of the receiver associated with this status.
|
|
||||||
/// </summary>
|
|
||||||
public int ReceiverId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the current status code.
|
|
||||||
/// </summary>
|
|
||||||
public Constants.DocumentStatus Status => Value is null ? Constants.DocumentStatus.Created : Constants.DocumentStatus.Signed;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the timestamp when the status was changed. Retrns the AddedWhen value.
|
|
||||||
/// </summary>
|
|
||||||
public DateTime StatusChangedWhen { get; } = DateTime.Now;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the display value associated with the status.
|
|
||||||
/// </summary>
|
|
||||||
public string? Value { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets timestamp when this record was added. Returns the current date and time.
|
|
||||||
/// </summary>
|
|
||||||
public virtual DateTime? ChangedWhen { get; } = DateTime.Now;
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user