diff --git a/dotnet/AipsCore/Domain/Abstract/DomainEntity.cs b/dotnet/AipsCore/Domain/Abstract/DomainEntity.cs new file mode 100644 index 0000000..90a43b5 --- /dev/null +++ b/dotnet/AipsCore/Domain/Abstract/DomainEntity.cs @@ -0,0 +1,26 @@ +using AipsCore.Domain.Common.ValueObjects; + +namespace AipsCore.Domain.Abstract; + +public abstract class DomainEntity where TId : DomainId +{ + private readonly List _domainEvents = []; + + public TId Id { get; init; } + + protected DomainEntity() + { + + } + + protected DomainEntity(TId id) + { + Id = id; + } + + public IReadOnlyList GetDomainEvents() => _domainEvents.ToList(); + + public void ClearDomainEvents() => _domainEvents.Clear(); + + protected void RaiseDomainEvent(IDomainEvent domainEvent) => _domainEvents.Add(domainEvent); +} \ No newline at end of file diff --git a/dotnet/AipsCore/Domain/Abstract/IAbstractRepository.cs b/dotnet/AipsCore/Domain/Abstract/IAbstractRepository.cs new file mode 100644 index 0000000..c41fbd6 --- /dev/null +++ b/dotnet/AipsCore/Domain/Abstract/IAbstractRepository.cs @@ -0,0 +1,12 @@ +using AipsCore.Domain.Common.ValueObjects; + +namespace AipsCore.Domain.Abstract; + +public interface IAbstractRepository + where TEntity : DomainEntity + where TId : DomainId +{ + Task GetByIdAsync(TId id, CancellationToken cancellationToken = default); + Task SaveAsync(TEntity entity, CancellationToken cancellationToken = default); + Task AddAsync(TEntity entity, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/dotnet/AipsCore/Domain/Abstract/IDomainEvent.cs b/dotnet/AipsCore/Domain/Abstract/IDomainEvent.cs new file mode 100644 index 0000000..75209ae --- /dev/null +++ b/dotnet/AipsCore/Domain/Abstract/IDomainEvent.cs @@ -0,0 +1,6 @@ +namespace AipsCore.Domain.Abstract; + +public interface IDomainEvent +{ + +} \ No newline at end of file