-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
446 additions
and
32 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/MunicipalityRegistry/Exceptions/CannotMergeMunicipalityWithSelfException.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,24 @@ | ||
namespace MunicipalityRegistry.Exceptions | ||
{ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
[Serializable] | ||
public sealed class CannotMergeMunicipalityWithSelfException : MunicipalityRegistryException | ||
{ | ||
public CannotMergeMunicipalityWithSelfException() | ||
{ } | ||
|
||
private CannotMergeMunicipalityWithSelfException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ } | ||
|
||
public CannotMergeMunicipalityWithSelfException(string message) | ||
: base(message) | ||
{ } | ||
|
||
public CannotMergeMunicipalityWithSelfException(string message, Exception inner) | ||
: base(message, inner) | ||
{ } | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ityRegistry/DuplicateLanguageException.cs → .../Exceptions/DuplicateLanguageException.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
2 changes: 1 addition & 1 deletion
2
...palityRegistry/InvalidPolygonException.cs → ...try/Exceptions/InvalidPolygonException.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
24 changes: 24 additions & 0 deletions
24
src/MunicipalityRegistry/Exceptions/MunicipalityHasInvalidStatusException.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,24 @@ | ||
namespace MunicipalityRegistry.Exceptions | ||
{ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
[Serializable] | ||
public sealed class MunicipalityHasInvalidStatusException : MunicipalityRegistryException | ||
{ | ||
public MunicipalityHasInvalidStatusException() | ||
{ } | ||
|
||
private MunicipalityHasInvalidStatusException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ } | ||
|
||
public MunicipalityHasInvalidStatusException(string message) | ||
: base(message) | ||
{ } | ||
|
||
public MunicipalityHasInvalidStatusException(string message, Exception inner) | ||
: base(message, inner) | ||
{ } | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...Registry/MunicipalityRegistryException.cs → ...ceptions/MunicipalityRegistryException.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
2 changes: 1 addition & 1 deletion
2
src/MunicipalityRegistry/NoNameException.cs → ...ityRegistry/Exceptions/NoNameException.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
2 changes: 1 addition & 1 deletion
2
...unicipalityRegistry/NoNisCodeException.cs → ...Registry/Exceptions/NoNisCodeException.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
2 changes: 1 addition & 1 deletion
2
...yRegistry/NoOfficialLanguagesException.cs → ...xceptions/NoOfficialLanguagesException.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
24 changes: 0 additions & 24 deletions
24
src/MunicipalityRegistry/Municipality/Commands/MergeMunicipalities.cs
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
src/MunicipalityRegistry/Municipality/Commands/MergeMunicipality.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,56 @@ | ||
namespace MunicipalityRegistry.Municipality.Commands | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Be.Vlaanderen.Basisregisters.Generators.Guid; | ||
using Be.Vlaanderen.Basisregisters.GrAr.Provenance; | ||
using Be.Vlaanderen.Basisregisters.Utilities; | ||
|
||
public sealed class MergeMunicipality : IHasCommandProvenance | ||
{ | ||
private static readonly Guid Namespace = new Guid("033e3688-38aa-4fe2-b9df-ba656b49cf70"); | ||
|
||
public MunicipalityId MunicipalityId { get; } | ||
|
||
public List<MunicipalityId> MunicipalityIdsToMergeWithWith { get; } | ||
|
||
public List<NisCode> NisCodesToMergeWith { get; } | ||
|
||
public MunicipalityId NewMunicipalityId { get; } | ||
|
||
public NisCode NewNisCode { get; } | ||
|
||
public Provenance Provenance { get; } | ||
|
||
public MergeMunicipality( | ||
MunicipalityId municipalityId, | ||
List<MunicipalityId> municipalityIdsToMergeWithWith, | ||
List<NisCode> nisCodesToMergeWith, | ||
MunicipalityId newMunicipalityId, | ||
NisCode newNisCode, | ||
Provenance provenance) | ||
{ | ||
MunicipalityId = municipalityId; | ||
MunicipalityIdsToMergeWithWith = municipalityIdsToMergeWithWith; | ||
NisCodesToMergeWith = nisCodesToMergeWith; | ||
NewMunicipalityId = newMunicipalityId; | ||
NewNisCode = newNisCode; | ||
Provenance = provenance; | ||
} | ||
|
||
public Guid CreateCommandId() | ||
=> Deterministic.Create(Namespace, $"{nameof(RegisterMunicipality)}-{ToString()}"); | ||
|
||
public override string? ToString() | ||
=> ToStringBuilder.ToString(IdentityFields()); | ||
|
||
private IEnumerable<object> IdentityFields() | ||
{ | ||
yield return MunicipalityId; | ||
yield return MunicipalityIdsToMergeWithWith; | ||
yield return NisCodesToMergeWith; | ||
yield return NewNisCode; | ||
yield return NewMunicipalityId; | ||
} | ||
} | ||
} |
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
71 changes: 71 additions & 0 deletions
71
src/MunicipalityRegistry/Municipality/Events/MunicipalityWasMerged.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,71 @@ | ||
namespace MunicipalityRegistry.Municipality.Events | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Be.Vlaanderen.Basisregisters.EventHandling; | ||
using Be.Vlaanderen.Basisregisters.GrAr.Provenance; | ||
using Newtonsoft.Json; | ||
|
||
[EventName("MunicipalityWasMerged")] | ||
[EventDescription("De gemeente werd gefusioneerd.")] | ||
public sealed class MunicipalityWasMerged : IHasProvenance, ISetProvenance, IMessage | ||
{ | ||
[EventPropertyDescription("Interne GUID van de gemeente.")] | ||
public Guid MunicipalityId { get; } | ||
|
||
[EventPropertyDescription("NIS-code (= objectidentificator) van de gemeente.")] | ||
public string NisCode { get; } | ||
|
||
[EventPropertyDescription("Interne GUIDs van de gemeenten waarmee gefusioneerd werd.")] | ||
public List<Guid> MunicipalityIdsToMergeWith { get; } | ||
|
||
[EventPropertyDescription("NIS-codes (= objectidentificatoren) van de gemeenten waarmee gefusioneerd werd.")] | ||
public List<string> NisCodesToMergeWith { get; } | ||
|
||
[EventPropertyDescription("Interne GUID van de nieuwe gemeente.")] | ||
public Guid NewMunicipalityId { get; } | ||
|
||
[EventPropertyDescription("NIS-code (= objectidentificator) van de nieuwe gemeente.")] | ||
public string NewNisCode { get; } | ||
|
||
[EventPropertyDescription("Metadata bij het event.")] | ||
public ProvenanceData Provenance { get; private set; } | ||
|
||
public MunicipalityWasMerged( | ||
MunicipalityId municipalityId, | ||
NisCode nisCode, | ||
IEnumerable<MunicipalityId> municipalityIdsToMergeWith, | ||
IEnumerable<NisCode> nisCodesToMergeWith, | ||
MunicipalityId newMunicipalityId, | ||
NisCode newNisCode) | ||
{ | ||
MunicipalityId = municipalityId; | ||
NisCode = nisCode; | ||
MunicipalityIdsToMergeWith = municipalityIdsToMergeWith.Select(x => (Guid)x).ToList(); | ||
NisCodesToMergeWith = nisCodesToMergeWith.Select(x => (string)x).ToList(); | ||
NewMunicipalityId = newMunicipalityId; | ||
NewNisCode = newNisCode; | ||
} | ||
|
||
[JsonConstructor] | ||
private MunicipalityWasMerged( | ||
Guid municipalityId, | ||
string nisCode, | ||
List<Guid> municipalityIdsToMergeWith, | ||
List<string> nisCodesToMergeWith, | ||
Guid newMunicipalityId, | ||
string newNisCode, | ||
ProvenanceData provenance) : this( | ||
new MunicipalityId(municipalityId), | ||
new NisCode(nisCode), | ||
municipalityIdsToMergeWith.Select(x => new MunicipalityId(x)).ToList(), | ||
nisCodesToMergeWith.Select(x => new NisCode(x)).ToList(), | ||
new MunicipalityId(newMunicipalityId), | ||
new NisCode(newNisCode)) => | ||
((ISetProvenance)this).SetProvenance(provenance.ToProvenance()); | ||
|
||
void ISetProvenance.SetProvenance(Provenance provenance) => Provenance = new ProvenanceData(provenance); | ||
|
||
} | ||
} |
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
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
Oops, something went wrong.