示例#1
0
 public ImportSubaddressFromCrab(
     CrabSubaddressId subaddressId,
     CrabHouseNumberId houseNumberId,
     BoxNumber boxNumber,
     CrabBoxNumberType boxNumberType,
     CrabLifetime lifetime,
     CrabTimestamp timestamp,
     CrabOperator @operator,
     CrabModification?modification,
     CrabOrganisation?organisation)
 {
     SubaddressId  = subaddressId;
     HouseNumberId = houseNumberId;
     BoxNumber     = boxNumber;
     Lifetime      = lifetime;
     Timestamp     = timestamp;
     Operator      = @operator;
     Modification  = modification;
     Organisation  = organisation;
     BoxNumberType = boxNumberType;
 }
示例#2
0
 public AddressSubaddressWasImportedFromCrab(
     CrabSubaddressId subaddressId,
     CrabHouseNumberId houseNumberId,
     BoxNumber boxNumber,
     CrabBoxNumberType boxNumberType,
     CrabLifetime lifetime,
     CrabTimestamp timestamp,
     CrabOperator @operator,
     CrabModification?modification,
     CrabOrganisation?organisation)
 {
     SubaddressId  = subaddressId;
     HouseNumberId = houseNumberId;
     BoxNumber     = boxNumber;
     BoxNumberType = boxNumberType;
     BeginDateTime = lifetime.BeginDateTime;
     EndDateTime   = lifetime.EndDateTime;
     Timestamp     = timestamp;
     Operator      = @operator;
     Modification  = modification;
     Organisation  = organisation;
 }
        public void ImportSubaddressFromCrab(
            CrabSubaddressId subaddressId,
            CrabHouseNumberId houseNumberId,
            BoxNumber boxNumber,
            CrabBoxNumberType boxNumberType,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            GuardRemoved(modification);

            var addressId = AddressId.CreateFor(subaddressId);

            if (_addressCollection.Contains(AddressId.CreateFor(houseNumberId)) &&
                !_addressCollection.Contains(addressId) &&
                modification != CrabModification.Delete &&
                !lifetime.EndDateTime.HasValue)
            {
                ApplyChange(new ParcelAddressWasAttached(_parcelId, addressId));
            }
            else if (_addressCollection.Contains(addressId) &&
                     (modification == CrabModification.Delete || lifetime.EndDateTime.HasValue))
            {
                ApplyChange(new ParcelAddressWasDetached(_parcelId, addressId));
            }

            ApplyChange(new AddressSubaddressWasImportedFromCrab(
                            subaddressId,
                            houseNumberId,
                            boxNumber,
                            boxNumberType,
                            lifetime,
                            timestamp,
                            @operator,
                            modification,
                            organisation));
        }
示例#4
0
        public void ImportSubaddressFromCrab(
            CrabSubaddressId subaddressId,
            CrabHouseNumberId houseNumberId,
            BoxNumber boxNumber,
            CrabBoxNumberType boxNumberType,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            GuardRemoved(modification);

            if (modification == CrabModification.Delete)
            {
                if (!IsRemoved)
                {
                    ApplyChange(new AddressWasRemoved(_addressId));
                }
            }
            else
            {
                if (_boxNumber != boxNumber)
                {
                    if (string.IsNullOrEmpty(boxNumber) && _boxNumber != null)
                    {
                        ApplyChange(new AddressBoxNumberWasRemoved(_addressId));
                    }
                    else if (modification != CrabModification.Correction)
                    {
                        ApplyChange(new AddressBoxNumberWasChanged(_addressId, boxNumber));
                    }
                    else
                    {
                        ApplyChange(new AddressBoxNumberWasCorrected(_addressId, boxNumber));
                    }
                }

                EvaluateRetirement(lifetime, modification);
            }

            if (_coupledHouseNumberId != null && _coupledHouseNumberId != houseNumberId && !IsRemoved)
            {
                var lastEvent = _lastHouseNumberEventsForSubaddress[houseNumberId];

                ApplyHouseNumberChange(new CrabStreetNameId(lastEvent.StreetNameId), new HouseNumber(lastEvent.HouseNumber), modification);

                ApplyPostalCodeChangeFor(
                    _lastHouseNumberMailCantonEventsForSubaddress.ContainsKey(houseNumberId)
                        ? _lastHouseNumberMailCantonEventsForSubaddress[houseNumberId]
                        : null,
                    modification);
            }

            ApplyChange(new AddressSubaddressWasImportedFromCrab(
                            subaddressId,
                            houseNumberId,
                            boxNumber,
                            boxNumberType,
                            lifetime,
                            timestamp,
                            @operator,
                            modification,
                            organisation));
        }