onebeyond/onebeyond-studio-core

View on GitHub
src/OneBeyond.Studio.Domain.SharedKernel/Entities/Commands/Delete.cs

Summary

Maintainability
A
35 mins
Test Coverage
using System.Collections.Generic;
using EnsureThat;
using OneBeyond.Studio.Domain.SharedKernel.RequestAuditors;

namespace OneBeyond.Studio.Domain.SharedKernel.Entities.Commands;

/// <summary>
/// Command for deleting aggregate root by Id
/// </summary>
/// <typeparam name="TAggregateRoot"></typeparam>
/// <typeparam name="TAggregateRootId"></typeparam>
public record Delete<TAggregateRoot, TAggregateRootId>
    : IAuditableRequest<TAggregateRootId>
    where TAggregateRoot : AggregateRoot<TAggregateRootId> 
{
    /// <summary>
    /// </summary>
    public Delete(TAggregateRootId aggregateRootId)
    {
        EnsureArg.IsFalse(
            EqualityComparer<TAggregateRootId>.Default.Equals(aggregateRootId, default!),
            nameof(aggregateRootId));

        AggregateRootId = aggregateRootId;
    }

    /// <summary>
    /// Id of an aggregate root to be deleted
    /// </summary>
    public TAggregateRootId AggregateRootId { get; }
}