private void When(ParcelSnapshot snapshot) { _parcelId = new ParcelId(snapshot.ParcelId); if (!string.IsNullOrEmpty(snapshot.ParcelStatus)) { var status = ParcelStatus.Parse(snapshot.ParcelStatus); if (status == ParcelStatus.Realized) { IsRealized = true; } if (status == ParcelStatus.Retired) { IsRetired = true; } } IsRemoved = snapshot.IsRemoved; LastModificationBasedOnCrab = snapshot.LastModificationBasedOnCrab; foreach (var activeHouseNumberByTerrainObject in snapshot.ActiveHouseNumberIdsByTerrainObjectHouseNr) { _activeHouseNumberIdsByTerreinObjectHouseNr.Add( new CrabTerrainObjectHouseNumberId(activeHouseNumberByTerrainObject.Key), new CrabHouseNumberId(activeHouseNumberByTerrainObject.Value)); } foreach (var addressId in snapshot.AddressIds) { _addressCollection.Add(new AddressId(addressId)); } foreach (var subaddressWasImportedFromCrab in snapshot.ImportedSubaddressFromCrab) { _addressCollection.Add(subaddressWasImportedFromCrab); } }
public static ParcelSnapshot WithAddressIds(this ParcelSnapshot snapshot, IEnumerable <AddressId> addressIds) { return(new ParcelSnapshot(new ParcelId(snapshot.ParcelId), string.IsNullOrEmpty(snapshot.ParcelStatus) ? null : ParcelStatus.Parse(snapshot.ParcelStatus), snapshot.IsRemoved, snapshot.LastModificationBasedOnCrab, snapshot.ActiveHouseNumberIdsByTerrainObjectHouseNr .ToDictionary( x => new CrabTerrainObjectHouseNumberId(x.Key), y => new CrabHouseNumberId(y.Value)), snapshot.ImportedSubaddressFromCrab, addressIds)); }
public static ParcelSnapshot WithActiveHouseNumberIdsByTerrainObjectHouseNr (this ParcelSnapshot snapshot, Dictionary <CrabTerrainObjectHouseNumberId, CrabHouseNumberId> activeHouseNumberIdsByTerrainObjectHouseNr) { return(new ParcelSnapshot(new ParcelId(snapshot.ParcelId), string.IsNullOrEmpty(snapshot.ParcelStatus) ? null : ParcelStatus.Parse(snapshot.ParcelStatus), snapshot.IsRemoved, snapshot.LastModificationBasedOnCrab, activeHouseNumberIdsByTerrainObjectHouseNr, snapshot.ImportedSubaddressFromCrab, snapshot.AddressIds.Select(x => new AddressId(x)))); }