Skip to content

Commit

Permalink
feat: add relink municipality
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneD authored and jvandaal committed Jul 16, 2024
1 parent 702cf2f commit 6fec88c
Show file tree
Hide file tree
Showing 34 changed files with 782 additions and 39 deletions.
14 changes: 7 additions & 7 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ nuget Be.Vlaanderen.Basisregisters.Projector 15.0.0

nuget Be.Vlaanderen.Basisregisters.Crab 4.0.0

nuget Be.Vlaanderen.Basisregisters.GrAr.Common 21.0.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Contracts 21.0.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Import 21.0.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Legacy 21.0.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Oslo 21.0.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Provenance 21.0.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Extracts 21.0.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Common 21.10.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Contracts 21.10.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Import 21.10.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Legacy 21.10.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Oslo 21.10.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Provenance 21.10.0
nuget Be.Vlaanderen.Basisregisters.GrAr.Extracts 21.10.0

nuget Be.Vlaanderen.Basisregisters.MessageHandling.Kafka.Producer 5.0.1

Expand Down
22 changes: 10 additions & 12 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,16 @@ NUGET
Autofac.Extensions.DependencyInjection (>= 9.0)
Be.Vlaanderen.Basisregisters.EventHandling (5.0)
Be.Vlaanderen.Basisregisters.Generators.Guid.Deterministic (4.0)
Be.Vlaanderen.Basisregisters.GrAr.Common (21.0)
Be.Vlaanderen.Basisregisters.GrAr.Common (21.10)
Be.Vlaanderen.Basisregisters.AggregateSource (>= 9.0.1)
Be.Vlaanderen.Basisregisters.CommandHandling (>= 9.0.1)
NetTopologySuite (>= 2.5)
NodaTime (>= 3.1.11)
Be.Vlaanderen.Basisregisters.GrAr.Contracts (21.0)
Be.Vlaanderen.Basisregisters.AggregateSource (>= 9.0.1)
NodaTime (>= 3.1.11)
Be.Vlaanderen.Basisregisters.GrAr.Extracts (21.0)
Be.Vlaanderen.Basisregisters.GrAr.Contracts (21.10)
Be.Vlaanderen.Basisregisters.GrAr.Extracts (21.10)
Be.Vlaanderen.Basisregisters.Api (>= 21.0)
Be.Vlaanderen.Basisregisters.Shaperon (>= 10.0.2)
Be.Vlaanderen.Basisregisters.GrAr.Import (21.0)
Be.Vlaanderen.Basisregisters.GrAr.Import (21.10)
Autofac (>= 8.0)
Be.Vlaanderen.Basisregisters.AggregateSource.SqlStreamStore (>= 9.0.1)
Be.Vlaanderen.Basisregisters.CommandHandling (>= 9.0.1)
Expand All @@ -243,21 +241,21 @@ NUGET
Serilog (>= 3.1.1)
Serilog.Extensions.Logging (>= 8.0)
System.Threading.Tasks.Dataflow (>= 8.0)
Be.Vlaanderen.Basisregisters.GrAr.Legacy (21.0)
Be.Vlaanderen.Basisregisters.GrAr.Common (21.0)
Be.Vlaanderen.Basisregisters.GrAr.Legacy (21.10)
Be.Vlaanderen.Basisregisters.GrAr.Common (21.10)
Be.Vlaanderen.Basisregisters.Utilities.Rfc3339DateTimeOffset (>= 4.0)
Newtonsoft.Json (>= 13.0.3)
Be.Vlaanderen.Basisregisters.GrAr.Oslo (21.0)
Be.Vlaanderen.Basisregisters.GrAr.Oslo (21.10)
Be.Vlaanderen.Basisregisters.AspNetCore.Mvc.Formatters.Json (>= 5.0)
Be.Vlaanderen.Basisregisters.GrAr.Common (21.0)
Be.Vlaanderen.Basisregisters.GrAr.Common (21.10)
Be.Vlaanderen.Basisregisters.Utilities.Rfc3339DateTimeOffset (>= 4.0)
Microsoft.Extensions.Configuration (>= 8.0)
Microsoft.Extensions.Http.Polly (>= 8.0.3)
Newtonsoft.Json (>= 13.0.3)
Be.Vlaanderen.Basisregisters.GrAr.Provenance (21.0)
Be.Vlaanderen.Basisregisters.GrAr.Provenance (21.10)
Be.Vlaanderen.Basisregisters.CommandHandling (>= 9.0.1)
Be.Vlaanderen.Basisregisters.Crab (>= 4.0)
Be.Vlaanderen.Basisregisters.GrAr.Common (21.0)
Be.Vlaanderen.Basisregisters.GrAr.Common (21.10)
Microsoft.CSharp (>= 4.7)
Be.Vlaanderen.Basisregisters.MessageHandling.Kafka.Producer (5.0.1)
Confluent.Kafka (>= 2.3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ protected override void Load(ContainerBuilder builder)
new IdempotencyTableInfo(Schema.Import),
_loggerFactory);

builder.RegisterType<IdempotentCommandHandler>()
.As<IIdempotentCommandHandler>()
.AsSelf()
.InstancePerLifetimeScope();

builder
.RegisterType<ProblemDetailsHelper>()
.AsSelf();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace PostalRegistry.Api.Import
{
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Be.Vlaanderen.Basisregisters.AggregateSource;
using Be.Vlaanderen.Basisregisters.Api.Exceptions;
using Be.Vlaanderen.Basisregisters.CommandHandling.Idempotency;
using FluentValidation;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PostalInformation.Commands;
using Relink;

public sealed partial class PostalInformationController
{
[HttpPost("{postcode}/relink-municipality")]
public async Task<IActionResult> RelinkMunicipality(
[FromRoute(Name = "postcode")]string? postalCode,
[FromBody] RelinkMunicipalityRequest request,
[FromServices] IValidator<RelinkMunicipalityRequest> validator,
[FromServices] IIdempotentCommandHandler idempotentCommandHandler,
CancellationToken cancellationToken = default)
{
request.PostalCode = postalCode;
await validator.ValidateAndThrowAsync(request, cancellationToken: cancellationToken);

try
{
var command = new RelinkMunicipality(
new PostalCode(postalCode!)
, new NisCode(request.NewNisCode!)
, CreateProvenance(request.Reason ?? string.Empty));

await idempotentCommandHandler.Dispatch(
command.CreateCommandId(),
command,
new Dictionary<string, object>(),
cancellationToken);

return Ok();
}
catch (AggregateNotFoundException)
{
throw new ApiException("Onbestaande postcode", StatusCodes.Status404NotFound);
}
}
}
}
26 changes: 26 additions & 0 deletions src/PostalRegistry.Api.Import/PostalInformationController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace PostalRegistry.Api.Import
{
using Asp.Versioning;
using Be.Vlaanderen.Basisregisters.Api;
using Be.Vlaanderen.Basisregisters.GrAr.Provenance;
using Microsoft.AspNetCore.Mvc;
using NodaTime;

[ApiVersion("1.0")]
[AdvertiseApiVersions("1.0")]
[ApiRoute("import")]
[ApiExplorerSettings(GroupName = "Import")]
public sealed partial class PostalInformationController : ApiController
{
private Provenance CreateProvenance(string reason, Modification modification = Modification.Update)
{
return new Provenance(
SystemClock.Instance.GetCurrentInstant(),
Application.PostalRegistry,
new Reason(reason),
new Operator("OVO002949"),
modification,
Organisation.DigitaalVlaanderen);
}
}
}

This file was deleted.

10 changes: 10 additions & 0 deletions src/PostalRegistry.Api.Import/Relink/RelinkMunicipalityRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace PostalRegistry.Api.Import.Relink
{
public sealed class RelinkMunicipalityRequest
{
public string? PostalCode { get; set; }
public string? NewNisCode { get; set; }

public string? Reason { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace PostalRegistry.Api.Import.Relink
{
using FluentValidation;

public sealed class RelinkMunicipalityRequestValidator : AbstractValidator<RelinkMunicipalityRequest>
{
public RelinkMunicipalityRequestValidator()
{
RuleFor(request => request.PostalCode)
.NotEmpty();

RuleFor(request => request.NewNisCode)
.NotEmpty()
.Length(5);
}
}
}
14 changes: 14 additions & 0 deletions src/PostalRegistry.Producer.Snapshot.Oslo/ProducerProjections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ await snapshotManager.FindMatchingSnapshot(
message.Position,
ct);
});

When<Envelope<MunicipalityWasRelinked>>(async (_, message, ct) =>
{
await FindAndProduce(async () =>
await snapshotManager.FindMatchingSnapshot(
message.Message.PostalCode,
message.Message.Provenance.Timestamp,
null,
message.Position,
throwStaleWhenGone: false,
ct),
message.Position,
ct);
});
}

private async Task FindAndProduce(
Expand Down
3 changes: 3 additions & 0 deletions src/PostalRegistry.Producer/Extensions/MessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ public static Contracts.PostalInformationPostalNameWasRemoved ToContract(this Do

public static Contracts.MunicipalityWasAttached ToContract(this Domain.MunicipalityWasAttached message) =>
new Contracts.MunicipalityWasAttached(message.PostalCode, message.NisCode, message.Provenance.ToContract());

public static Contracts.MunicipalityWasRelinked ToContract(this Domain.MunicipalityWasRelinked message) =>
new Contracts.MunicipalityWasRelinked(message.PostalCode, message.NewNisCode, message.PreviousNisCode, message.Provenance.ToContract());
}
}
5 changes: 5 additions & 0 deletions src/PostalRegistry.Producer/ProducerProjections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public ProducerProjections(IProducer producer)
{
await Produce(message.Message.PostalCode, message.Message.ToContract(), message.Position, ct);
});

When<Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Envelope<Domain.MunicipalityWasRelinked>>(async (_, message, ct) =>
{
await Produce(message.Message.PostalCode, message.Message.ToContract(), message.Position, ct);
});
}

private async Task Produce<T>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ await context.FindAndUpdatePostal(
ct);
});

When<Envelope<MunicipalityWasRelinked>>(async (context, message, ct) =>
{
await context.FindAndUpdatePostal(
message.Message.PostalCode,
postalInformation =>
{
postalInformation.NisCode = message.Message.NewNisCode;
UpdateVersionTimestamp(postalInformation, message.Message.Provenance.Timestamp);
},
ct);
});

When<Envelope<PostalInformationWasRealized>>(async (context, message, ct) =>
{
await context.FindAndUpdatePostal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ public LastChangedListProjections()
await GetLastChangedRecordsAndUpdatePosition(message.Message.PostalCode, message.Position, context, ct);
});

When<Envelope<MunicipalityWasAttached>>(async (context, message, ct) => await DoNothing());
When<Envelope<MunicipalityWasAttached>>(async (context, message, ct) =>
{
await GetLastChangedRecordsAndUpdatePosition(message.Message.PostalCode, message.Position, context, ct);
});

When<Envelope<MunicipalityWasRelinked>>(async (context, message, ct) =>
{
await GetLastChangedRecordsAndUpdatePosition(message.Message.PostalCode, message.Position, context, ct);
});

When<Envelope<PostalInformationWasImportedFromCrab>>(async (context, message, ct) => await DoNothing());
When<Envelope<PostalInformationWasImportedFromBPost>>(async (context, message, ct) => await DoNothing());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ await context.FindAndUpdatePostalInformation(
ct);
});

When<Envelope<MunicipalityWasRelinked>>(async (context, message, ct) =>
{
await context.FindAndUpdatePostalInformation(
message.Message.PostalCode,
postalInformation =>
{
postalInformation.NisCode = message.Message.NewNisCode;
UpdateVersionTimestamp(postalInformation, message.Message.Provenance.Timestamp);
},
ct);
});

When<Envelope<PostalInformationWasRealized>>(async (context, message, ct) =>
{
await context.FindAndUpdatePostalInformation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ await context.CreateNewPostalInformationSyndicationItem(
ct);
});

When<Envelope<MunicipalityWasRelinked>>(async (context, message, ct) =>
{
await context.CreateNewPostalInformationSyndicationItem(
message.Message.PostalCode,
message,
x => x.MunicipalityNisCode = message.Message.NewNisCode,
ct);
});

When<Envelope<PostalInformationWasImportedFromCrab>>(async (context, message, ct) => await DoNothing());
When<Envelope<PostalInformationWasImportedFromBPost>>(async (context, message, ct) => await DoNothing());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum MunicipalityEvent
MunicipalityFacilityLanguageWasRemoved,

MunicipalityWasDrawn,
MunicipalityWasMerged,
MunicipalityGeometryWasCleared,
MunicipalityGeometryWasCorrected,
MunicipalityGeometryWasCorrectedToCleared,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public MunicipalityLatestProjections()
When(MunicipalityEvent.MunicipalityGeometryWasCorrectedToCleared, DoNothing);
When(MunicipalityEvent.MunicipalityBecameCurrent, DoNothing);
When(MunicipalityEvent.MunicipalityWasRetired, DoNothing);
When(MunicipalityEvent.MunicipalityWasMerged, DoNothing);
When(MunicipalityEvent.MunicipalityWasCorrectedToCurrent, DoNothing);
When(MunicipalityEvent.MunicipalityWasCorrectedToRetired, DoNothing);
}
Expand Down
7 changes: 7 additions & 0 deletions src/PostalRegistry/CommandHandlerModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace PostalRegistry
{
using Autofac;
using Be.Vlaanderen.Basisregisters.CommandHandling;
using Be.Vlaanderen.Basisregisters.GrAr.Provenance;
using PostalInformation;

public static class CommandHandlerModules
Expand All @@ -16,6 +17,12 @@ public static void Register(ContainerBuilder containerBuilder)
.RegisterType<CrabPostalInformationProvenanceFactory>()
.SingleInstance();

containerBuilder
.RegisterType<PostalInformationProvenanceFactory>()
.As<IProvenanceFactory<PostalInformation.PostalInformation>>()
.AsSelf()
.SingleInstance();

containerBuilder
.RegisterType<PostalInformationCommandHandlerModule>()
.Named<CommandHandlerModule>(typeof(PostalInformationCommandHandlerModule).FullName)

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Extract / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Extract / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Legacy / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Legacy / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Legacy / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Oslo / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Oslo / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Oslo / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Import / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Import / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Api Import / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Producer / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Producer / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Producer / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Producer Snapshot Oslo / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Producer Snapshot Oslo / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Producer Snapshot Oslo / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Projections Syndication / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Projections Syndication / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Projections Syndication / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Projector / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Projector / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Build Projector / build-image

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Pack Api Legacy / pack

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Pack Api Legacy / pack

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Pack Api Extract / pack

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Pack Api Oslo / pack

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.

Check warning on line 28 in src/PostalRegistry/CommandHandlerModules.cs

View workflow job for this annotation

GitHub Actions / Pack Api Oslo / pack

Possible null reference argument for parameter 'serviceName' in 'IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle> IRegistrationBuilder<PostalInformationCommandHandlerModule, ConcreteReflectionActivatorData, SingleRegistrationStyle>.Named<CommandHandlerModule>(string serviceName)'.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace PostalRegistry.PostalInformation.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 RelinkMunicipality : IHasCommandProvenance
{
private static readonly Guid Namespace = new Guid("461f480c-75d9-4637-b98e-5fd66682d338");

public PostalCode PostalCode { get; }
public NisCode NewNisCode { get; }
public Provenance Provenance { get; }

public RelinkMunicipality(PostalCode postalCode, NisCode newNisCode, Provenance provenance)
{
PostalCode = postalCode;
NewNisCode = newNisCode;
Provenance = provenance;
}

public Guid CreateCommandId()
=> Deterministic.Create(Namespace, $"RelinkMunicipality-{ToString()}");

public override string? ToString()
=> ToStringBuilder.ToString(IdentityFields());

private IEnumerable<object> IdentityFields()
{
yield return PostalCode;
yield return NewNisCode;

foreach (var field in Provenance.GetIdentityFields())
{
yield return field;
}
}
}
}
Loading

0 comments on commit 6fec88c

Please sign in to comment.