private void ApplyHouseNumberChange( CrabStreetNameId crabStreetNameId, HouseNumber houseNumber, CrabModification?modification) { if (HouseNumber != houseNumber) { if (modification != CrabModification.Correction) { ApplyChange(new AddressHouseNumberWasChanged(_addressId, houseNumber)); } else { ApplyChange(new AddressHouseNumberWasCorrected(_addressId, houseNumber)); } } var streetNameId = StreetNameId.CreateFor(crabStreetNameId); if (streetNameId == StreetNameId) { return; } if (modification != CrabModification.Correction) { ApplyChange(new AddressStreetNameWasChanged(_addressId, streetNameId)); } else { ApplyChange(new AddressStreetNameWasCorrected(_addressId, streetNameId)); } }
public async Task ImportStreetNameStatusFromCrab( Func <IStreetNames> getStreetNames, CommandMessage <ImportStreetNameStatusFromCrab> message, CancellationToken ct) { var streetNames = getStreetNames(); var streetNameId = StreetNameId.CreateFor(message.Command.StreetNameId); var streetName = await streetNames.GetAsync(streetNameId, ct); ImportStatusFromCrab(streetName, message.Command); }
public void GivenNoStreetNameThenAddressStreetNameWasChanged( Fixture fixture, AddressId addressId, StreetNameId streetNameId, ImportHouseNumberFromCrab importHouseNumberFromCrab) { importHouseNumberFromCrab = importHouseNumberFromCrab .WithStreetNameId(new Fixture().Customize(new WithStreetNameIdExcept(streetNameId)).Create <CrabStreetNameId>()); Assert(RegisteredAddressScenario(fixture) .When(importHouseNumberFromCrab) .Then(addressId, new AddressStreetNameWasChanged(addressId, StreetNameId.CreateFor(importHouseNumberFromCrab.StreetNameId)), importHouseNumberFromCrab.ToLegacyEvent())); }
public async Task ImportStreetNameFromCrab( Func <IStreetNames> getStreetNames, CommandMessage <ImportStreetNameFromCrab> message, CancellationToken ct) { var streetNames = getStreetNames(); var streetNameId = StreetNameId.CreateFor(message.Command.StreetNameId); var municipalityId = MunicipalityId.CreateFor(message.Command.MunicipalityId); var streetName = await GetOrRegisterStreetName( streetNames, streetNameId, municipalityId, message.Command.NisCode, ct); ImportFromCrab(streetName.Value, message.Command); }
public async Task ImportHouseNumberFromCrab(Func <IAddresses> getAddresses, CommandMessage <ImportHouseNumberFromCrab> message, CancellationToken ct) { var addresses = getAddresses(); var addressId = AddressId.CreateFor(message.Command.HouseNumberId); var streetNameId = StreetNameId.CreateFor(message.Command.StreetNameId); var address = await GetOrRegisterAddress(addresses, addressId, streetNameId, message.Command.HouseNumber, ct); if (!address.HasValue) { address = new Optional <Address>( Address.Register( new AddressId(addressId), new StreetNameId(streetNameId), message.Command.HouseNumber)); addresses.Add(addressId, address.Value); } ImportHouseNumberFromCrab(address.Value, message.Command); }