diff --git a/backend/src/Logitar.Portal.Application/Logitar.Portal.Application.csproj b/backend/src/Logitar.Portal.Application/Logitar.Portal.Application.csproj index bf12b992..2bb9927d 100644 --- a/backend/src/Logitar.Portal.Application/Logitar.Portal.Application.csproj +++ b/backend/src/Logitar.Portal.Application/Logitar.Portal.Application.csproj @@ -52,7 +52,7 @@ - + diff --git a/backend/src/Logitar.Portal.Client/Logitar.Portal.Client.csproj b/backend/src/Logitar.Portal.Client/Logitar.Portal.Client.csproj index ed8f2654..7fa7ff5d 100644 --- a/backend/src/Logitar.Portal.Client/Logitar.Portal.Client.csproj +++ b/backend/src/Logitar.Portal.Client/Logitar.Portal.Client.csproj @@ -51,7 +51,7 @@ - + diff --git a/backend/src/Logitar.Portal.Contracts/Logitar.Portal.Contracts.csproj b/backend/src/Logitar.Portal.Contracts/Logitar.Portal.Contracts.csproj index ecc9e3bf..aa07a89c 100644 --- a/backend/src/Logitar.Portal.Contracts/Logitar.Portal.Contracts.csproj +++ b/backend/src/Logitar.Portal.Contracts/Logitar.Portal.Contracts.csproj @@ -52,7 +52,7 @@ - + diff --git a/backend/src/Logitar.Portal.Domain/Configurations/ConfigurationAggregate.cs b/backend/src/Logitar.Portal.Domain/Configurations/ConfigurationAggregate.cs index 747c9cd3..fa9a1d00 100644 --- a/backend/src/Logitar.Portal.Domain/Configurations/ConfigurationAggregate.cs +++ b/backend/src/Logitar.Portal.Domain/Configurations/ConfigurationAggregate.cs @@ -100,12 +100,13 @@ public static ConfigurationAggregate Initialize(ActorId actorId) ConfigurationId id = new(); ConfigurationAggregate configuration = new(id.AggregateId); + LocaleUnit? defaultLocale = null; JwtSecretUnit secret = JwtSecretUnit.Generate(); ReadOnlyUniqueNameSettings uniqueNameSettings = new(); ReadOnlyPasswordSettings passordSettings = new(); bool requireUniqueEmail = true; ReadOnlyLoggingSettings loggingSettings = new(); - configuration.Raise(new ConfigurationInitializedEvent(actorId, defaultLocale: null, secret, uniqueNameSettings, passordSettings, requireUniqueEmail, loggingSettings)); + configuration.Raise(new ConfigurationInitializedEvent(defaultLocale, secret, uniqueNameSettings, passordSettings, requireUniqueEmail, loggingSettings), actorId); return configuration; } @@ -125,8 +126,7 @@ public void Update(ActorId actorId) { if (_updatedEvent.HasChanges) { - _updatedEvent.ActorId = actorId; - Raise(_updatedEvent); + Raise(_updatedEvent, actorId, DateTime.Now); _updatedEvent = new(); } } diff --git a/backend/src/Logitar.Portal.Domain/Configurations/Events/ConfigurationInitializedEvent.cs b/backend/src/Logitar.Portal.Domain/Configurations/Events/ConfigurationInitializedEvent.cs index 0ad94ec0..81bf73a6 100644 --- a/backend/src/Logitar.Portal.Domain/Configurations/Events/ConfigurationInitializedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Configurations/Events/ConfigurationInitializedEvent.cs @@ -5,26 +5,5 @@ namespace Logitar.Portal.Domain.Configurations.Events; -public record ConfigurationInitializedEvent : DomainEvent, INotification -{ - public LocaleUnit? DefaultLocale { get; } - public JwtSecretUnit Secret { get; } - - public ReadOnlyUniqueNameSettings UniqueNameSettings { get; } - public ReadOnlyPasswordSettings PasswordSettings { get; } - public bool RequireUniqueEmail { get; } - - public ReadOnlyLoggingSettings LoggingSettings { get; } - - public ConfigurationInitializedEvent(ActorId actorId, LocaleUnit? defaultLocale, JwtSecretUnit secret, ReadOnlyUniqueNameSettings uniqueNameSettings, - ReadOnlyPasswordSettings passwordSettings, bool requireUniqueEmail, ReadOnlyLoggingSettings loggingSettings) - { - ActorId = actorId; - DefaultLocale = defaultLocale; - Secret = secret; - UniqueNameSettings = uniqueNameSettings; - PasswordSettings = passwordSettings; - RequireUniqueEmail = requireUniqueEmail; - LoggingSettings = loggingSettings; - } -} +public record ConfigurationInitializedEvent(LocaleUnit? DefaultLocale, JwtSecretUnit Secret, ReadOnlyUniqueNameSettings UniqueNameSettings, + ReadOnlyPasswordSettings PasswordSettings, bool RequireUniqueEmail, ReadOnlyLoggingSettings LoggingSettings) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Dictionaries/DictionaryAggregate.cs b/backend/src/Logitar.Portal.Domain/Dictionaries/DictionaryAggregate.cs index 92e94d86..5f35f832 100644 --- a/backend/src/Logitar.Portal.Domain/Dictionaries/DictionaryAggregate.cs +++ b/backend/src/Logitar.Portal.Domain/Dictionaries/DictionaryAggregate.cs @@ -26,7 +26,7 @@ public DictionaryAggregate(AggregateId id) : base(id) public DictionaryAggregate(LocaleUnit locale, TenantId? tenantId = null, ActorId actorId = default, DictionaryId? id = null) : base((id ?? DictionaryId.NewId()).AggregateId) { - Raise(new DictionaryCreatedEvent(actorId, locale, tenantId)); + Raise(new DictionaryCreatedEvent(tenantId, locale), actorId); } protected virtual void Apply(DictionaryCreatedEvent @event) { @@ -39,7 +39,7 @@ public void Delete(ActorId actorId = default) { if (!IsDeleted) { - Raise(new DictionaryDeletedEvent(actorId)); + Raise(new DictionaryDeletedEvent(), actorId); } } @@ -71,7 +71,7 @@ public void SetLocale(LocaleUnit locale, ActorId actorId = default) { if (locale != _locale) { - Raise(new DictionaryLocaleChangedEvent(actorId, locale)); + Raise(new DictionaryLocaleChangedEvent(locale), actorId); } } protected virtual void Apply(DictionaryLocaleChangedEvent @event) @@ -85,8 +85,7 @@ public void Update(ActorId actorId = default) { if (_updatedEvent.HasChanges) { - _updatedEvent.ActorId = actorId; - Raise(_updatedEvent); + Raise(_updatedEvent, actorId, DateTime.Now); _updatedEvent = new(); } } diff --git a/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryCreatedEvent.cs b/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryCreatedEvent.cs index 362e0485..cc96867d 100644 --- a/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryCreatedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryCreatedEvent.cs @@ -4,16 +4,4 @@ namespace Logitar.Portal.Domain.Dictionaries.Events; -public record DictionaryCreatedEvent : DomainEvent, INotification -{ - public TenantId? TenantId { get; } - - public LocaleUnit Locale { get; } - - public DictionaryCreatedEvent(ActorId actorId, LocaleUnit locale, TenantId? tenantId) - { - ActorId = actorId; - Locale = locale; - TenantId = tenantId; - } -} +public record DictionaryCreatedEvent(TenantId? TenantId, LocaleUnit Locale) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryDeletedEvent.cs b/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryDeletedEvent.cs index 467c193f..f2a609ae 100644 --- a/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryDeletedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryDeletedEvent.cs @@ -5,9 +5,8 @@ namespace Logitar.Portal.Domain.Dictionaries.Events; public record DictionaryDeletedEvent : DomainEvent, INotification { - public DictionaryDeletedEvent(ActorId actorId) + public DictionaryDeletedEvent() { - ActorId = actorId; IsDeleted = true; } } diff --git a/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryLocaleChangedEvent.cs b/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryLocaleChangedEvent.cs index 7959bc8d..32067a42 100644 --- a/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryLocaleChangedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Dictionaries/Events/DictionaryLocaleChangedEvent.cs @@ -4,13 +4,4 @@ namespace Logitar.Portal.Domain.Dictionaries.Events; -public record DictionaryLocaleChangedEvent : DomainEvent, INotification -{ - public LocaleUnit Locale { get; } - - public DictionaryLocaleChangedEvent(ActorId actorId, LocaleUnit locale) - { - ActorId = actorId; - Locale = locale; - } -} +public record DictionaryLocaleChangedEvent(LocaleUnit Locale) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Logitar.Portal.Domain.csproj b/backend/src/Logitar.Portal.Domain/Logitar.Portal.Domain.csproj index 667e4af0..96e618bc 100644 --- a/backend/src/Logitar.Portal.Domain/Logitar.Portal.Domain.csproj +++ b/backend/src/Logitar.Portal.Domain/Logitar.Portal.Domain.csproj @@ -51,7 +51,7 @@ - + diff --git a/backend/src/Logitar.Portal.Domain/Messages/Events/MessageCreatedEvent.cs b/backend/src/Logitar.Portal.Domain/Messages/Events/MessageCreatedEvent.cs index ce28ff47..5d9a8750 100644 --- a/backend/src/Logitar.Portal.Domain/Messages/Events/MessageCreatedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Messages/Events/MessageCreatedEvent.cs @@ -5,37 +5,6 @@ namespace Logitar.Portal.Domain.Messages.Events; -public record MessageCreatedEvent : DomainEvent, INotification -{ - public TenantId? TenantId { get; } - - public SubjectUnit Subject { get; } - public ContentUnit Body { get; } - - public IReadOnlyCollection Recipients { get; } - public SenderSummary Sender { get; } - public TemplateSummary Template { get; } - - public bool IgnoreUserLocale { get; } - public LocaleUnit? Locale { get; } - - public IReadOnlyDictionary Variables { get; } - - public bool IsDemo { get; } - - public MessageCreatedEvent(ActorId actorId, TenantId? tenantId, SubjectUnit subject, ContentUnit body, IReadOnlyCollection recipients, - SenderSummary sender, TemplateSummary template, bool ignoreUserLocale, LocaleUnit? locale, IReadOnlyDictionary variables, bool isDemo) - { - ActorId = actorId; - TenantId = tenantId; - Subject = subject; - Body = body; - Recipients = recipients; - Sender = sender; - Template = template; - IgnoreUserLocale = ignoreUserLocale; - Locale = locale; - Variables = variables; - IsDemo = isDemo; - } -} +public record MessageCreatedEvent(TenantId? TenantId, SubjectUnit Subject, ContentUnit Body, IReadOnlyCollection Recipients, + SenderSummary Sender, TemplateSummary Template, bool IgnoreUserLocale, LocaleUnit? Locale, IReadOnlyDictionary Variables, bool IsDemo) + : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Messages/Events/MessageDeletedEvent.cs b/backend/src/Logitar.Portal.Domain/Messages/Events/MessageDeletedEvent.cs index c538e7d6..39701add 100644 --- a/backend/src/Logitar.Portal.Domain/Messages/Events/MessageDeletedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Messages/Events/MessageDeletedEvent.cs @@ -5,9 +5,8 @@ namespace Logitar.Portal.Domain.Messages.Events; public record MessageDeletedEvent : DomainEvent, INotification { - public MessageDeletedEvent(ActorId actorId) + public MessageDeletedEvent() { - ActorId = actorId; IsDeleted = true; } } diff --git a/backend/src/Logitar.Portal.Domain/Messages/Events/MessageFailedEvent.cs b/backend/src/Logitar.Portal.Domain/Messages/Events/MessageFailedEvent.cs index de0914dd..fe6a4813 100644 --- a/backend/src/Logitar.Portal.Domain/Messages/Events/MessageFailedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Messages/Events/MessageFailedEvent.cs @@ -3,13 +3,4 @@ namespace Logitar.Portal.Domain.Messages.Events; -public record MessageFailedEvent : DomainEvent, INotification -{ - public IReadOnlyDictionary ResultData { get; } - - public MessageFailedEvent(ActorId actorId, IReadOnlyDictionary resultData) - { - ActorId = actorId; - ResultData = resultData; - } -} +public record MessageFailedEvent(IReadOnlyDictionary ResultData) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Messages/Events/MessageSucceededEvent.cs b/backend/src/Logitar.Portal.Domain/Messages/Events/MessageSucceededEvent.cs index efdad521..9fb3ca34 100644 --- a/backend/src/Logitar.Portal.Domain/Messages/Events/MessageSucceededEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Messages/Events/MessageSucceededEvent.cs @@ -3,13 +3,4 @@ namespace Logitar.Portal.Domain.Messages.Events; -public record MessageSucceededEvent : DomainEvent, INotification -{ - public IReadOnlyDictionary ResultData { get; } - - public MessageSucceededEvent(ActorId actorId, IReadOnlyDictionary resultData) - { - ActorId = actorId; - ResultData = resultData; - } -} +public record MessageSucceededEvent(IReadOnlyDictionary ResultData) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Messages/MessageAggregate.cs b/backend/src/Logitar.Portal.Domain/Messages/MessageAggregate.cs index ce04ce9f..72d0b38c 100644 --- a/backend/src/Logitar.Portal.Domain/Messages/MessageAggregate.cs +++ b/backend/src/Logitar.Portal.Domain/Messages/MessageAggregate.cs @@ -79,8 +79,8 @@ public MessageAggregate(SubjectUnit subject, ContentUnit body, IReadOnlyCollecti throw new TemplateNotInTenantException(template, tenantId); } - Raise(new MessageCreatedEvent(actorId, tenantId, subject, body, recipients, new SenderSummary(sender), - new TemplateSummary(template), ignoreUserLocale, locale, variables ?? new Dictionary(), isDemo)); + Raise(new MessageCreatedEvent(tenantId, subject, body, recipients, new SenderSummary(sender), new TemplateSummary(template), + ignoreUserLocale, locale, variables ?? new Dictionary(), isDemo), actorId); } protected virtual void Apply(MessageCreatedEvent @event) { @@ -112,7 +112,7 @@ public void Delete(ActorId actorId = default) { if (!IsDeleted) { - Raise(new MessageDeletedEvent(actorId)); + Raise(new MessageDeletedEvent(), actorId); } } @@ -121,7 +121,7 @@ public void Fail(IReadOnlyDictionary resultData, ActorId actorId { if (Status == MessageStatus.Unsent) { - Raise(new MessageFailedEvent(actorId, resultData)); + Raise(new MessageFailedEvent(resultData), actorId); } } protected virtual void Apply(MessageFailedEvent @event) @@ -140,7 +140,7 @@ public void Succeed(IReadOnlyDictionary resultData, ActorId acto { if (Status == MessageStatus.Unsent) { - Raise(new MessageSucceededEvent(actorId, resultData)); + Raise(new MessageSucceededEvent(resultData), actorId); } } protected virtual void Apply(MessageSucceededEvent @event) diff --git a/backend/src/Logitar.Portal.Domain/Realms/Events/RealmCreatedEvent.cs b/backend/src/Logitar.Portal.Domain/Realms/Events/RealmCreatedEvent.cs index 9eed6d2c..7cbc711e 100644 --- a/backend/src/Logitar.Portal.Domain/Realms/Events/RealmCreatedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Realms/Events/RealmCreatedEvent.cs @@ -4,24 +4,5 @@ namespace Logitar.Portal.Domain.Realms.Events; -public record RealmCreatedEvent : DomainEvent, INotification -{ - public UniqueSlugUnit UniqueSlug { get; } - - public JwtSecretUnit Secret { get; } - - public ReadOnlyUniqueNameSettings UniqueNameSettings { get; } - public ReadOnlyPasswordSettings PasswordSettings { get; } - public bool RequireUniqueEmail { get; } - - public RealmCreatedEvent(ActorId actorId, UniqueSlugUnit uniqueSlug, JwtSecretUnit secret, ReadOnlyUniqueNameSettings uniqueNameSettings, - ReadOnlyPasswordSettings passwordSettings, bool requireUniqueEmail) - { - ActorId = actorId; - UniqueSlug = uniqueSlug; - Secret = secret; - UniqueNameSettings = uniqueNameSettings; - PasswordSettings = passwordSettings; - RequireUniqueEmail = requireUniqueEmail; - } -} +public record RealmCreatedEvent(UniqueSlugUnit UniqueSlug, JwtSecretUnit Secret, ReadOnlyUniqueNameSettings UniqueNameSettings, + ReadOnlyPasswordSettings PasswordSettings, bool RequireUniqueEmail) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Realms/Events/RealmDeletedEvent.cs b/backend/src/Logitar.Portal.Domain/Realms/Events/RealmDeletedEvent.cs index 433aefaf..28bcbaf8 100644 --- a/backend/src/Logitar.Portal.Domain/Realms/Events/RealmDeletedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Realms/Events/RealmDeletedEvent.cs @@ -5,9 +5,8 @@ namespace Logitar.Portal.Domain.Realms.Events; public record RealmDeletedEvent : DomainEvent, INotification { - public RealmDeletedEvent(ActorId actorId) + public RealmDeletedEvent() { - ActorId = actorId; IsDeleted = true; } } diff --git a/backend/src/Logitar.Portal.Domain/Realms/Events/RealmUniqueSlugChangedEvent.cs b/backend/src/Logitar.Portal.Domain/Realms/Events/RealmUniqueSlugChangedEvent.cs index 77707c8f..f85f0cd2 100644 --- a/backend/src/Logitar.Portal.Domain/Realms/Events/RealmUniqueSlugChangedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Realms/Events/RealmUniqueSlugChangedEvent.cs @@ -3,13 +3,4 @@ namespace Logitar.Portal.Domain.Realms.Events; -public record RealmUniqueSlugChangedEvent : DomainEvent, INotification -{ - public UniqueSlugUnit UniqueSlug { get; } - - public RealmUniqueSlugChangedEvent(ActorId actorId, UniqueSlugUnit uniqueSlug) - { - ActorId = actorId; - UniqueSlug = uniqueSlug; - } -} +public record RealmUniqueSlugChangedEvent(UniqueSlugUnit UniqueSlug) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Realms/RealmAggregate.cs b/backend/src/Logitar.Portal.Domain/Realms/RealmAggregate.cs index 8cb111b2..a581cbd1 100644 --- a/backend/src/Logitar.Portal.Domain/Realms/RealmAggregate.cs +++ b/backend/src/Logitar.Portal.Domain/Realms/RealmAggregate.cs @@ -134,7 +134,7 @@ public RealmAggregate(UniqueSlugUnit uniqueSlug, ActorId actorId = default, Real ReadOnlyUniqueNameSettings uniqueNameSettings = new(); ReadOnlyPasswordSettings passwordSettings = new(); bool requireUniqueEmail = true; - Raise(new RealmCreatedEvent(actorId, uniqueSlug, secret, uniqueNameSettings, passwordSettings, requireUniqueEmail)); + Raise(new RealmCreatedEvent(uniqueSlug, secret, uniqueNameSettings, passwordSettings, requireUniqueEmail), actorId); } protected virtual void Apply(RealmCreatedEvent @event) { @@ -149,7 +149,7 @@ public void Delete(ActorId actorId = default) { if (!IsDeleted) { - Raise(new RealmDeletedEvent(actorId)); + Raise(new RealmDeletedEvent(), actorId); } } @@ -180,7 +180,7 @@ public void SetCustomAttribute(string key, string value) public void SetUniqueSlug(UniqueSlugUnit uniqueSlug, ActorId actorId = default) { - Raise(new RealmUniqueSlugChangedEvent(actorId, uniqueSlug)); + Raise(new RealmUniqueSlugChangedEvent(uniqueSlug), actorId); } protected virtual void Apply(RealmUniqueSlugChangedEvent @event) { @@ -191,8 +191,7 @@ public void Update(ActorId actorId = default) { if (_updatedEvent.HasChanges) { - _updatedEvent.ActorId = actorId; - Raise(_updatedEvent); + Raise(_updatedEvent, actorId, DateTime.Now); _updatedEvent = new(); } } diff --git a/backend/src/Logitar.Portal.Domain/Senders/Events/EmailSenderCreatedEvent.cs b/backend/src/Logitar.Portal.Domain/Senders/Events/EmailSenderCreatedEvent.cs index 872ec3f0..eb168fb3 100644 --- a/backend/src/Logitar.Portal.Domain/Senders/Events/EmailSenderCreatedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Senders/Events/EmailSenderCreatedEvent.cs @@ -1,5 +1,4 @@ -using Logitar.EventSourcing; -using Logitar.Identity.Domain.Shared; +using Logitar.Identity.Domain.Shared; using Logitar.Identity.Domain.Users; using Logitar.Portal.Contracts.Senders; using MediatR; @@ -8,7 +7,7 @@ namespace Logitar.Portal.Domain.Senders.Events; public record EmailSenderCreatedEvent : SenderCreatedEvent, INotification { - public EmailSenderCreatedEvent(ActorId actorId, EmailUnit email, SenderProvider provider, TenantId? tenantId) : base(actorId, email, provider, tenantId) + public EmailSenderCreatedEvent(TenantId? tenantId, EmailUnit email, SenderProvider provider) : base(tenantId, email, provider) { } } diff --git a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderCreatedEvent.cs b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderCreatedEvent.cs index a70ba0f7..14b9e8ec 100644 --- a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderCreatedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderCreatedEvent.cs @@ -6,19 +6,4 @@ namespace Logitar.Portal.Domain.Senders.Events; -public record SenderCreatedEvent : DomainEvent, INotification -{ - public TenantId? TenantId { get; } - - public EmailUnit Email { get; } - - public SenderProvider Provider { get; } - - public SenderCreatedEvent(ActorId actorId, EmailUnit email, SenderProvider provider, TenantId? tenantId) - { - ActorId = actorId; - Email = email; - Provider = provider; - TenantId = tenantId; - } -} +public record SenderCreatedEvent(TenantId? TenantId, EmailUnit Email, SenderProvider Provider) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderDeletedEvent.cs b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderDeletedEvent.cs index ac529f02..323bdd55 100644 --- a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderDeletedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderDeletedEvent.cs @@ -5,9 +5,8 @@ namespace Logitar.Portal.Domain.Senders.Events; public record SenderDeletedEvent : DomainEvent, INotification { - public SenderDeletedEvent(ActorId actorId) + public SenderDeletedEvent() { - ActorId = actorId; IsDeleted = true; } } diff --git a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderMailgunSettingsChangedEvent.cs b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderMailgunSettingsChangedEvent.cs index cedd5952..c4494642 100644 --- a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderMailgunSettingsChangedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderMailgunSettingsChangedEvent.cs @@ -4,13 +4,4 @@ namespace Logitar.Portal.Domain.Senders.Events; -public record SenderMailgunSettingsChangedEvent : DomainEvent, INotification -{ - public ReadOnlyMailgunSettings Settings { get; } - - public SenderMailgunSettingsChangedEvent(ActorId actorId, ReadOnlyMailgunSettings settings) - { - ActorId = actorId; - Settings = settings; - } -} +public record SenderMailgunSettingsChangedEvent(ReadOnlyMailgunSettings Settings) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderSendGridSettingsChangedEvent.cs b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderSendGridSettingsChangedEvent.cs index 215463bd..42236e4d 100644 --- a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderSendGridSettingsChangedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderSendGridSettingsChangedEvent.cs @@ -4,13 +4,4 @@ namespace Logitar.Portal.Domain.Senders.Events; -public record SenderSendGridSettingsChangedEvent : DomainEvent, INotification -{ - public ReadOnlySendGridSettings Settings { get; } - - public SenderSendGridSettingsChangedEvent(ActorId actorId, ReadOnlySendGridSettings settings) - { - ActorId = actorId; - Settings = settings; - } -} +public record SenderSendGridSettingsChangedEvent(ReadOnlySendGridSettings Settings) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderSetDefaultEvent.cs b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderSetDefaultEvent.cs index 1446fe19..c4060d50 100644 --- a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderSetDefaultEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderSetDefaultEvent.cs @@ -3,13 +3,4 @@ namespace Logitar.Portal.Domain.Senders.Events; -public record SenderSetDefaultEvent : DomainEvent, INotification -{ - public bool IsDefault { get; } - - public SenderSetDefaultEvent(ActorId actorId, bool isDefault) - { - ActorId = actorId; - IsDefault = isDefault; - } -} +public record SenderSetDefaultEvent(bool IsDefault) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderTwilioSettingsChangedEvent.cs b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderTwilioSettingsChangedEvent.cs index cc9a099b..e3d89943 100644 --- a/backend/src/Logitar.Portal.Domain/Senders/Events/SenderTwilioSettingsChangedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Senders/Events/SenderTwilioSettingsChangedEvent.cs @@ -4,13 +4,4 @@ namespace Logitar.Portal.Domain.Senders.Events; -public record SenderTwilioSettingsChangedEvent : DomainEvent, INotification -{ - public ReadOnlyTwilioSettings Settings { get; } - - public SenderTwilioSettingsChangedEvent(ActorId actorId, ReadOnlyTwilioSettings settings) - { - ActorId = actorId; - Settings = settings; - } -} +public record SenderTwilioSettingsChangedEvent(ReadOnlyTwilioSettings Settings) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Senders/Events/SmsSenderCreatedEvent.cs b/backend/src/Logitar.Portal.Domain/Senders/Events/SmsSenderCreatedEvent.cs index 1d4bfb63..3c67293c 100644 --- a/backend/src/Logitar.Portal.Domain/Senders/Events/SmsSenderCreatedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Senders/Events/SmsSenderCreatedEvent.cs @@ -6,19 +6,4 @@ namespace Logitar.Portal.Domain.Senders.Events; -public record SmsSenderCreatedEvent : DomainEvent, INotification -{ - public TenantId? TenantId { get; } - - public PhoneUnit Phone { get; } - - public SenderProvider Provider { get; } - - public SmsSenderCreatedEvent(ActorId actorId, PhoneUnit phone, SenderProvider provider, TenantId? tenantId) - { - ActorId = actorId; - Phone = phone; - Provider = provider; - TenantId = tenantId; - } -} +public record SmsSenderCreatedEvent(TenantId? TenantId, PhoneUnit Phone, SenderProvider Provider) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Senders/SenderAggregate.cs b/backend/src/Logitar.Portal.Domain/Senders/SenderAggregate.cs index 5aef1b0d..f42f03e8 100644 --- a/backend/src/Logitar.Portal.Domain/Senders/SenderAggregate.cs +++ b/backend/src/Logitar.Portal.Domain/Senders/SenderAggregate.cs @@ -111,11 +111,11 @@ private SenderAggregate(EmailUnit? email, PhoneUnit? phone, SenderSettings setti { case SenderType.Email: ArgumentNullException.ThrowIfNull(email); - Raise(new EmailSenderCreatedEvent(actorId, email, provider, tenantId)); + Raise(new EmailSenderCreatedEvent(tenantId, email, provider), actorId); break; case SenderType.Sms: ArgumentNullException.ThrowIfNull(phone); - Raise(new SmsSenderCreatedEvent(actorId, phone, provider, tenantId)); + Raise(new SmsSenderCreatedEvent(tenantId, phone, provider), actorId); break; default: throw new SenderTypeNotSupportedException(type); @@ -163,7 +163,7 @@ public void Delete(ActorId actorId = default) { if (!IsDeleted) { - Raise(new SenderDeletedEvent(actorId)); + Raise(new SenderDeletedEvent(), actorId); } } @@ -172,7 +172,7 @@ public void SetDefault(bool isDefault, ActorId actorId = default) { if (isDefault != IsDefault) { - Raise(new SenderSetDefaultEvent(actorId, isDefault)); + Raise(new SenderSetDefaultEvent(isDefault), actorId); } } protected virtual void Apply(SenderSetDefaultEvent @event) @@ -188,7 +188,7 @@ public void SetSettings(ReadOnlyMailgunSettings settings, ActorId actorId = defa } else if (settings != _settings) { - Raise(new SenderMailgunSettingsChangedEvent(actorId, settings)); + Raise(new SenderMailgunSettingsChangedEvent(settings), actorId); } } protected virtual void Apply(SenderMailgunSettingsChangedEvent @event) @@ -204,7 +204,7 @@ public void SetSettings(ReadOnlySendGridSettings settings, ActorId actorId = def } else if (settings != _settings) { - Raise(new SenderSendGridSettingsChangedEvent(actorId, settings)); + Raise(new SenderSendGridSettingsChangedEvent(settings), actorId); } } protected virtual void Apply(SenderSendGridSettingsChangedEvent @event) @@ -220,7 +220,7 @@ public void SetSettings(ReadOnlyTwilioSettings settings, ActorId actorId = defau } else if (settings != _settings) { - Raise(new SenderTwilioSettingsChangedEvent(actorId, settings)); + Raise(new SenderTwilioSettingsChangedEvent(settings), actorId); } } protected virtual void Apply(SenderTwilioSettingsChangedEvent @event) @@ -232,8 +232,7 @@ public void Update(ActorId actorId = default) { if (_updatedEvent.HasChanges) { - _updatedEvent.ActorId = actorId; - Raise(_updatedEvent); + Raise(_updatedEvent, actorId, DateTime.Now); _updatedEvent = new(); } } diff --git a/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateCreatedEvent.cs b/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateCreatedEvent.cs index fa4a07ee..658a0cfb 100644 --- a/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateCreatedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateCreatedEvent.cs @@ -4,21 +4,4 @@ namespace Logitar.Portal.Domain.Templates.Events; -public record TemplateCreatedEvent : DomainEvent, INotification -{ - public TenantId? TenantId { get; } - - public UniqueKeyUnit UniqueKey { get; } - - public SubjectUnit Subject { get; } - public ContentUnit Content { get; } - - public TemplateCreatedEvent(ActorId actorId, ContentUnit content, SubjectUnit subject, TenantId? tenantId, UniqueKeyUnit uniqueKey) - { - ActorId = actorId; - Content = content; - Subject = subject; - TenantId = tenantId; - UniqueKey = uniqueKey; - } -} +public record TemplateCreatedEvent(TenantId? TenantId, UniqueKeyUnit UniqueKey, SubjectUnit Subject, ContentUnit Content) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateDeletedEvent.cs b/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateDeletedEvent.cs index b3f68edd..fef799b0 100644 --- a/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateDeletedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateDeletedEvent.cs @@ -5,9 +5,8 @@ namespace Logitar.Portal.Domain.Templates.Events; public record TemplateDeletedEvent : DomainEvent, INotification { - public TemplateDeletedEvent(ActorId actorId) + public TemplateDeletedEvent() { - ActorId = actorId; IsDeleted = true; } } diff --git a/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateUniqueKeyChangedEvent.cs b/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateUniqueKeyChangedEvent.cs index 35e3664c..e6314a4c 100644 --- a/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateUniqueKeyChangedEvent.cs +++ b/backend/src/Logitar.Portal.Domain/Templates/Events/TemplateUniqueKeyChangedEvent.cs @@ -3,13 +3,4 @@ namespace Logitar.Portal.Domain.Templates.Events; -public record TemplateUniqueKeyChangedEvent : DomainEvent, INotification -{ - public UniqueKeyUnit UniqueKey { get; } - - public TemplateUniqueKeyChangedEvent(ActorId actorId, UniqueKeyUnit uniqueKey) - { - ActorId = actorId; - UniqueKey = uniqueKey; - } -} +public record TemplateUniqueKeyChangedEvent(UniqueKeyUnit UniqueKey) : DomainEvent, INotification; diff --git a/backend/src/Logitar.Portal.Domain/Templates/TemplateAggregate.cs b/backend/src/Logitar.Portal.Domain/Templates/TemplateAggregate.cs index 27b7130e..857c5b70 100644 --- a/backend/src/Logitar.Portal.Domain/Templates/TemplateAggregate.cs +++ b/backend/src/Logitar.Portal.Domain/Templates/TemplateAggregate.cs @@ -76,7 +76,7 @@ public TemplateAggregate(AggregateId id) : base(id) public TemplateAggregate(UniqueKeyUnit uniqueKey, SubjectUnit subject, ContentUnit content, TenantId? tenantId = null, ActorId actorId = default, TemplateId? id = null) : base((id ?? TemplateId.NewId()).AggregateId) { - Raise(new TemplateCreatedEvent(actorId, content, subject, tenantId, uniqueKey)); + Raise(new TemplateCreatedEvent(tenantId, uniqueKey, subject, content), actorId); } protected virtual void Apply(TemplateCreatedEvent @event) { @@ -92,7 +92,7 @@ public void Delete(ActorId actorId = default) { if (!IsDeleted) { - Raise(new TemplateDeletedEvent(actorId)); + Raise(new TemplateDeletedEvent(), actorId); } } @@ -100,7 +100,7 @@ public void SetUniqueKey(UniqueKeyUnit uniqueKey, ActorId actorId = default) { if (uniqueKey != _uniqueKey) { - Raise(new TemplateUniqueKeyChangedEvent(actorId, uniqueKey)); + Raise(new TemplateUniqueKeyChangedEvent(uniqueKey), actorId); } } protected virtual void Apply(TemplateUniqueKeyChangedEvent @event) @@ -112,8 +112,7 @@ public void Update(ActorId actorId = default) { if (_updatedEvent.HasChanges) { - _updatedEvent.ActorId = actorId; - Raise(_updatedEvent); + Raise(_updatedEvent, actorId, DateTime.Now); _updatedEvent = new(); } } diff --git a/backend/src/Logitar.Portal.Domain/Templates/Validators/ContentTypeValidator.cs b/backend/src/Logitar.Portal.Domain/Templates/Validators/ContentTypeValidator.cs index 57b6e7f0..c6926e3b 100644 --- a/backend/src/Logitar.Portal.Domain/Templates/Validators/ContentTypeValidator.cs +++ b/backend/src/Logitar.Portal.Domain/Templates/Validators/ContentTypeValidator.cs @@ -5,11 +5,7 @@ namespace Logitar.Portal.Domain.Templates.Validators; internal class ContentTypeValidator : AbstractValidator { - private static readonly HashSet _contentTypes = new(new[] - { - MediaTypeNames.Text.Html, - MediaTypeNames.Text.Plain - }); + private static readonly HashSet _contentTypes = new([MediaTypeNames.Text.Html, MediaTypeNames.Text.Plain]); public ContentTypeValidator(string? propertyName = null) { diff --git a/backend/src/Logitar.Portal.EntityFrameworkCore.PostgreSQL/Logitar.Portal.EntityFrameworkCore.PostgreSQL.csproj b/backend/src/Logitar.Portal.EntityFrameworkCore.PostgreSQL/Logitar.Portal.EntityFrameworkCore.PostgreSQL.csproj index 6ac642bc..2be4727a 100644 --- a/backend/src/Logitar.Portal.EntityFrameworkCore.PostgreSQL/Logitar.Portal.EntityFrameworkCore.PostgreSQL.csproj +++ b/backend/src/Logitar.Portal.EntityFrameworkCore.PostgreSQL/Logitar.Portal.EntityFrameworkCore.PostgreSQL.csproj @@ -51,7 +51,7 @@ - + diff --git a/backend/src/Logitar.Portal.EntityFrameworkCore.Relational/Logitar.Portal.EntityFrameworkCore.Relational.csproj b/backend/src/Logitar.Portal.EntityFrameworkCore.Relational/Logitar.Portal.EntityFrameworkCore.Relational.csproj index fa6d0f06..b294d259 100644 --- a/backend/src/Logitar.Portal.EntityFrameworkCore.Relational/Logitar.Portal.EntityFrameworkCore.Relational.csproj +++ b/backend/src/Logitar.Portal.EntityFrameworkCore.Relational/Logitar.Portal.EntityFrameworkCore.Relational.csproj @@ -64,7 +64,7 @@ - + diff --git a/backend/src/Logitar.Portal.EntityFrameworkCore.SqlServer/Logitar.Portal.EntityFrameworkCore.SqlServer.csproj b/backend/src/Logitar.Portal.EntityFrameworkCore.SqlServer/Logitar.Portal.EntityFrameworkCore.SqlServer.csproj index 9d537fe0..0c9f32ed 100644 --- a/backend/src/Logitar.Portal.EntityFrameworkCore.SqlServer/Logitar.Portal.EntityFrameworkCore.SqlServer.csproj +++ b/backend/src/Logitar.Portal.EntityFrameworkCore.SqlServer/Logitar.Portal.EntityFrameworkCore.SqlServer.csproj @@ -51,7 +51,7 @@ - + diff --git a/backend/src/Logitar.Portal.Infrastructure/Logitar.Portal.Infrastructure.csproj b/backend/src/Logitar.Portal.Infrastructure/Logitar.Portal.Infrastructure.csproj index bfc3c650..b6e563e0 100644 --- a/backend/src/Logitar.Portal.Infrastructure/Logitar.Portal.Infrastructure.csproj +++ b/backend/src/Logitar.Portal.Infrastructure/Logitar.Portal.Infrastructure.csproj @@ -51,7 +51,7 @@ - + diff --git a/backend/src/Logitar.Portal.MassTransit/Logitar.Portal.MassTransit.csproj b/backend/src/Logitar.Portal.MassTransit/Logitar.Portal.MassTransit.csproj index 8366265c..e22fa0ce 100644 --- a/backend/src/Logitar.Portal.MassTransit/Logitar.Portal.MassTransit.csproj +++ b/backend/src/Logitar.Portal.MassTransit/Logitar.Portal.MassTransit.csproj @@ -51,7 +51,7 @@ - + diff --git a/backend/src/Logitar.Portal.Worker/Logitar.Portal.Worker.csproj b/backend/src/Logitar.Portal.Worker/Logitar.Portal.Worker.csproj index b80e4832..9b0e54e2 100644 --- a/backend/src/Logitar.Portal.Worker/Logitar.Portal.Worker.csproj +++ b/backend/src/Logitar.Portal.Worker/Logitar.Portal.Worker.csproj @@ -28,7 +28,7 @@ - + diff --git a/backend/src/Logitar.Portal/Logitar.Portal.csproj b/backend/src/Logitar.Portal/Logitar.Portal.csproj index a80306c0..b3ee9083 100644 --- a/backend/src/Logitar.Portal/Logitar.Portal.csproj +++ b/backend/src/Logitar.Portal/Logitar.Portal.csproj @@ -30,12 +30,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + +