-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add StreetNameWasRenamed event
- Loading branch information
Showing
9 changed files
with
110 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
src/AddressRegistry/StreetName/Commands/RetireAddressesBecauseStreetNameWasRenamed.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/AddressRegistry/StreetName/Events/StreetNameWasRenamed.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace AddressRegistry.StreetName.Events | ||
{ | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using Be.Vlaanderen.Basisregisters.EventHandling; | ||
using Be.Vlaanderen.Basisregisters.GrAr.Common; | ||
using Be.Vlaanderen.Basisregisters.GrAr.Provenance; | ||
using Newtonsoft.Json; | ||
|
||
[EventTags(Tag.StreetName)] | ||
[EventName(EventName)] | ||
[EventDescription("De straatnaam werd hernoemd.")] | ||
public class StreetNameWasRenamed : IStreetNameEvent | ||
{ | ||
public const string EventName = "StreetNameWasRenamed"; // BE CAREFUL CHANGING THIS!! | ||
|
||
public int StreetNamePersistentLocalId { get; } | ||
public int DestinationStreetNamePersistentLocalId { get; } | ||
public ProvenanceData Provenance { get; private set; } | ||
|
||
public StreetNameWasRenamed( | ||
StreetNamePersistentLocalId streetNamePersistentLocalId, | ||
StreetNamePersistentLocalId destinationStreetNamePersistentLocalId) | ||
{ | ||
StreetNamePersistentLocalId = streetNamePersistentLocalId; | ||
DestinationStreetNamePersistentLocalId = destinationStreetNamePersistentLocalId; | ||
} | ||
|
||
[JsonConstructor] | ||
private StreetNameWasRenamed( | ||
int streetNamePersistentLocalId, | ||
int destinationStreetNamePersistentLocalId, | ||
ProvenanceData provenance) | ||
: this( | ||
new StreetNamePersistentLocalId(streetNamePersistentLocalId), | ||
new StreetNamePersistentLocalId(destinationStreetNamePersistentLocalId)) | ||
=> ((ISetProvenance)this).SetProvenance(provenance.ToProvenance()); | ||
|
||
void ISetProvenance.SetProvenance(Provenance provenance) => Provenance = new ProvenanceData(provenance); | ||
|
||
public IEnumerable<string> GetHashFields() | ||
{ | ||
var fields = Provenance.GetHashFields().ToList(); | ||
fields.Add(StreetNamePersistentLocalId.ToString(CultureInfo.InvariantCulture)); | ||
fields.Add(DestinationStreetNamePersistentLocalId.ToString(CultureInfo.InvariantCulture)); | ||
return fields; | ||
} | ||
|
||
public string GetHash() => this.ToEventHash(EventName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters