diff --git a/services/Directory/FilterLists.Directory.Domain/Aggregates/Changes/FilterListChange.cs b/services/Directory/FilterLists.Directory.Domain/Aggregates/Changes/FilterListChange.cs index e9af78ac3..15b651635 100644 --- a/services/Directory/FilterLists.Directory.Domain/Aggregates/Changes/FilterListChange.cs +++ b/services/Directory/FilterLists.Directory.Domain/Aggregates/Changes/FilterListChange.cs @@ -12,9 +12,9 @@ private FilterListChange() public FilterList? Before { get; private init; } public FilterList? After { get; private init; } - public static FilterListChange Create(string? reason) + public static FilterListChange Create(FilterList filterList, string? reason) { - return new FilterListChange { Reason = reason }; + return new FilterListChange { After = filterList, Reason = reason }; } public static FilterListChange Update(FilterList before, FilterList after, string? reason) diff --git a/services/Directory/FilterLists.Directory.Domain/Aggregates/FilterLists/FilterList.cs b/services/Directory/FilterLists.Directory.Domain/Aggregates/FilterLists/FilterList.cs index c6b1700b5..ec94e5ffd 100644 --- a/services/Directory/FilterLists.Directory.Domain/Aggregates/FilterLists/FilterList.cs +++ b/services/Directory/FilterLists.Directory.Domain/Aggregates/FilterLists/FilterList.cs @@ -5,7 +5,7 @@ namespace FilterLists.Directory.Domain.Aggregates.FilterLists; public sealed class FilterList : AggregateRoot, IRequireChangeApproval { - private readonly ICollection _changes = new HashSet(); + private ICollection _changes = new HashSet(); private FilterList() { @@ -24,12 +24,7 @@ private FilterList() public string? EmailAddress { get; private init; } public Uri? DonateUrl { get; private init; } public IReadOnlyCollection ViewUrls { get; private init; } = new HashSet(); - - public IReadOnlyCollection Changes - { - get => (IReadOnlyCollection)_changes; - private init => _changes = (ICollection)value; - } + public IReadOnlyCollection Changes => (IReadOnlyCollection)_changes; public static FilterList Create( string name, @@ -47,13 +42,14 @@ public static FilterList Create( IEnumerable<(short SegmentNumber, short Primariness, Uri Url)> viewUrls, string? createReason) { - var urls = viewUrls.Select(u => FilterListViewUrl.Create(u.SegmentNumber, u.Primariness, u.Url)).ToList(); + var urls = viewUrls.Select(u => FilterListViewUrl.Create(u.SegmentNumber, u.Primariness, u.Url)) + .ToList(); if (urls.Count == 0) { throw new ArgumentException("At lest one view URL is required.", nameof(viewUrls)); } - return new FilterList + var list = new FilterList { Name = name, Description = description, @@ -67,8 +63,9 @@ public static FilterList Create( ChatUrl = chatUrl, EmailAddress = emailAddress, DonateUrl = donateUrl, - ViewUrls = urls, - Changes = new HashSet(new[] { FilterListChange.Create(createReason) }) + ViewUrls = urls }; + list._changes = new HashSet(new[] { FilterListChange.Create(list, createReason) }); + return list; } }