Esempio n. 1
0
        public AddressResponse(
            string naamruimte,
            string objectId,
            string huisnummer,
            string busnummer,
            AdresDetailGemeente gemeente,
            AdresDetailStraatnaam straatnaam,
            HomoniemToevoeging homoniemToevoeging,
            AdresDetailPostinfo postInfo,
            Point adresPositie,
            PositieGeometrieMethode positieGeometrieMethode,
            PositieSpecificatie positieSpecificatie,
            AdresStatus status,
            Taal taal,
            bool?officieelToegekend,
            DateTimeOffset version)
        {
            Identificator           = new AdresIdentificator(naamruimte, objectId, version);
            Huisnummer              = huisnummer;
            Busnummer               = busnummer;
            PositieGeometrieMethode = positieGeometrieMethode;
            PositieSpecificatie     = positieSpecificatie;
            AdresStatus             = status;
            OfficieelToegekend      = officieelToegekend ?? false;
            Postinfo           = postInfo;
            Gemeente           = gemeente;
            Straatnaam         = straatnaam;
            HomoniemToevoeging = homoniemToevoeging;
            AdresPositie       = adresPositie;

            VolledigAdres = new VolledigAdres(
                straatnaam?.Straatnaam?.GeografischeNaam?.Spelling,
                huisnummer,
                busnummer,
                postInfo?.ObjectId,
                gemeente?.Gemeentenaam?.GeografischeNaam?.Spelling,
                taal);
        }
Esempio n. 2
0
        public async Task <IActionResult> Get(
            [FromServices] LegacyContext context,
            [FromServices] SyndicationContext syndicationContext,
            [FromServices] IOptions <ResponseOptions> responseOptions,
            [FromRoute] int persistentLocalId,
            [FromRoute] Taal?taal,
            CancellationToken cancellationToken = default)
        {
            var address = await context
                          .AddressDetail
                          .AsNoTracking()
                          .SingleOrDefaultAsync(item => item.PersistentLocalId == persistentLocalId, cancellationToken);

            if (address != null && address.Removed)
            {
                throw new ApiException("Adres werd verwijderd.", StatusCodes.Status410Gone);
            }

            if (address == null || !address.Complete)
            {
                throw new ApiException("Onbestaand adres.", StatusCodes.Status404NotFound);
            }

            var streetName = await syndicationContext.StreetNameLatestItems.FindAsync(new object[] { address.StreetNameId }, cancellationToken);

            var municipality = await syndicationContext.MunicipalityLatestItems.FirstAsync(m => m.NisCode == streetName.NisCode, cancellationToken);

            var defaultMunicipalityName = AddressMapper.GetDefaultMunicipalityName(municipality);
            var defaultStreetName       = AddressMapper.GetDefaultStreetNameName(streetName, municipality.PrimaryLanguage);
            var defaultHomonymAddition  = AddressMapper.GetDefaultHomonymAddition(streetName, municipality.PrimaryLanguage);

            var gemeente = new AdresDetailGemeente(
                municipality.NisCode,
                string.Format(responseOptions.Value.GemeenteDetailUrl, municipality.NisCode),
                new GeografischeNaam(defaultMunicipalityName.Value, defaultMunicipalityName.Key));

            var straat = new AdresDetailStraatnaam(
                streetName.PersistentLocalId,
                string.Format(responseOptions.Value.StraatnaamDetailUrl, streetName.PersistentLocalId),
                new GeografischeNaam(defaultStreetName.Value, defaultStreetName.Key));

            var postInfo = string.IsNullOrEmpty(address.PostalCode)
                ? null
                : new AdresDetailPostinfo(
                address.PostalCode,
                string.Format(responseOptions.Value.PostInfoDetailUrl, address.PostalCode));

            var homoniemToevoeging = defaultHomonymAddition == null
                ? null
                : new HomoniemToevoeging(new GeografischeNaam(defaultHomonymAddition.Value.Value, defaultHomonymAddition.Value.Key));

            return(Ok(
                       new AddressResponse(
                           responseOptions.Value.Naamruimte,
                           address.PersistentLocalId.ToString(),
                           address.HouseNumber,
                           address.BoxNumber,
                           gemeente,
                           straat,
                           homoniemToevoeging,
                           postInfo,
                           AddressMapper.GetAddressPoint(address.Position),
                           AddressMapper.ConvertFromGeometryMethod(address.PositionMethod),
                           AddressMapper.ConvertFromGeometrySpecification(address.PositionSpecification),
                           AddressMapper.ConvertFromAddressStatus(address.Status),
                           defaultStreetName.Key,
                           address.OfficiallyAssigned,
                           address.VersionTimestamp.ToBelgianDateTimeOffset())));
        }