public static ImportTerrainObjectHouseNumberFromCrab WithTerrainObjectHouseNumberId( this ImportTerrainObjectHouseNumberFromCrab command, CrabTerrainObjectHouseNumberId terrainObjectHouseNumberId) { return(new ImportTerrainObjectHouseNumberFromCrab( command.CaPaKey, terrainObjectHouseNumberId, command.TerrainObjectId, command.HouseNumberId, command.Lifetime, command.Timestamp, command.Operator, command.Modification, command.Organisation)); }
private void When(TerrainObjectHouseNumberWasImportedFromCrab @event) { var crabTerrainObjectHouseNumberId = new CrabTerrainObjectHouseNumberId(@event.TerrainObjectHouseNumberId); var crabHouseNumberId = new CrabHouseNumberId(@event.HouseNumberId); if (@event.Modification == CrabModification.Delete) { _activeHouseNumberIdsByTerreinObjectHouseNr.Remove(crabTerrainObjectHouseNumberId); } else { _activeHouseNumberIdsByTerreinObjectHouseNr[crabTerrainObjectHouseNumberId] = crabHouseNumberId; } WhenCrabEventApplied(); }
public TerrainObjectHouseNumberWasImportedFromCrab( CrabTerrainObjectHouseNumberId terrainObjectHouseNumberId, CrabTerrainObjectId terrainObjectId, CrabHouseNumberId houseNumberId, CrabLifetime lifetime, CrabTimestamp timestamp, CrabOperator @operator, CrabModification?modification, CrabOrganisation?organisation) { TerrainObjectHouseNumberId = terrainObjectHouseNumberId; TerrainObjectId = terrainObjectId; HouseNumberId = houseNumberId; BeginDateTime = lifetime.BeginDateTime; EndDateTime = lifetime.EndDateTime; Timestamp = timestamp; Operator = @operator; Modification = modification; Organisation = organisation; }
public ImportTerrainObjectHouseNumberFromCrab( VbrCaPaKey caPaKey, CrabTerrainObjectHouseNumberId terrainObjectHouseNumberId, CrabTerrainObjectId terrainObjectId, CrabHouseNumberId houseNumberId, CrabLifetime lifetime, CrabTimestamp timestamp, CrabOperator @operator, CrabModification?modification, CrabOrganisation?organisation) { CaPaKey = caPaKey; TerrainObjectHouseNumberId = terrainObjectHouseNumberId; TerrainObjectId = terrainObjectId; HouseNumberId = houseNumberId; Lifetime = lifetime; Timestamp = timestamp; Operator = @operator; Modification = modification; Organisation = organisation; }
public void ImportTerrainObjectHouseNumberFromCrab( CrabTerrainObjectHouseNumberId terrainObjectHouseNumberId, CrabTerrainObjectId terrainObjectId, CrabHouseNumberId houseNumberId, CrabLifetime lifetime, CrabTimestamp timestamp, CrabOperator @operator, CrabModification?modification, CrabOrganisation?organisation) { GuardRemoved(modification); var legacyEvent = new TerrainObjectHouseNumberWasImportedFromCrab( terrainObjectHouseNumberId, terrainObjectId, houseNumberId, lifetime, timestamp, @operator, modification, organisation); var addressId = AddressId.CreateFor(houseNumberId); if (_addressCollection.Contains(addressId) && (modification == CrabModification.Delete || lifetime.EndDateTime.HasValue)) { if (_activeHouseNumberIdsByTerreinObjectHouseNr.Values.Count(x => x == houseNumberId) == 1) { foreach (var addressIdToRemove in _addressCollection.AddressIdsEligableToRemoveFor(houseNumberId)) { ApplyChange(new ParcelAddressWasDetached(_parcelId, addressIdToRemove)); } ApplyChange(new ParcelAddressWasDetached(_parcelId, addressId)); } } else { if (_activeHouseNumberIdsByTerreinObjectHouseNr.ContainsKey(terrainObjectHouseNumberId) && _activeHouseNumberIdsByTerreinObjectHouseNr[terrainObjectHouseNumberId] != houseNumberId) { var currentCrabHouseNumberId = _activeHouseNumberIdsByTerreinObjectHouseNr[terrainObjectHouseNumberId]; if (_activeHouseNumberIdsByTerreinObjectHouseNr.Values.Count(x => x == currentCrabHouseNumberId) == 1) { foreach (var addressIdToRemove in _addressCollection.AddressIdsEligableToRemoveFor( currentCrabHouseNumberId)) { ApplyChange(new ParcelAddressWasDetached(_parcelId, addressIdToRemove)); } ApplyChange(new ParcelAddressWasDetached(_parcelId, AddressId.CreateFor(currentCrabHouseNumberId))); } } if (!_addressCollection.Contains(addressId) && modification != CrabModification.Delete && !lifetime.EndDateTime.HasValue) { ApplyChange(new ParcelAddressWasAttached(_parcelId, addressId)); foreach (var addressIdToAdd in _addressCollection.AddressIdsEligableToAddFor(houseNumberId)) { ApplyChange(new ParcelAddressWasAttached(_parcelId, addressIdToAdd)); } } } ApplyChange(legacyEvent); }