示例#1
0
        internal override async Task <TDestination> MapAsync <TDestination>(object source, CancellationToken cancellationToken)
        {
            var group = source as LocalAuthority;

            if (group == null)
            {
                throw new ArgumentException(
                          $"source must be an LocalAuthority, but received {source.GetType().FullName}", nameof(source));
            }

            if (typeof(TDestination) != typeof(ManagementGroup))
            {
                throw new ArgumentException(
                          $"TDestination must be ManagementGroup, but received {typeof(TDestination).FullName}",
                          nameof(source));
            }

            var managementGroup = new ManagementGroup
            {
                Name       = group.Name,
                Identifier = group.Code.ToString(),
            };

            managementGroup.Type =
                await TranslateAsync(EnumerationNames.ManagementGroupType, LocalAuthority.ManagementGroupType, cancellationToken);

            managementGroup.Code = $"{managementGroup.Type}-{managementGroup.Identifier}";

            managementGroup.SetLineageForRequestedFields();
            return(managementGroup as TDestination);
        }
        internal override async Task <TDestination> MapAsync <TDestination>(object source, CancellationToken cancellationToken)
        {
            var group = source as Group;

            if (group == null)
            {
                throw new ArgumentException(
                          $"source must be an Group, but received {source.GetType().FullName}", nameof(source));
            }

            if (typeof(TDestination) != typeof(ManagementGroup))
            {
                throw new ArgumentException(
                          $"TDestination must be ManagementGroup, but received {typeof(TDestination).FullName}",
                          nameof(source));
            }

            var managementGroup = new ManagementGroup
            {
                Name                 = group.GroupName,
                Identifier           = group.Uid.ToString(),
                CompaniesHouseNumber = group.CompaniesHouseNumber,
                Ukprn                = group.Ukprn,
                AddressLine1         = group.GroupStreet,
                AddressLine2         = group.GroupLocality,
                AddressLine3         = group.GroupAddress3,
                Town                 = group.GroupTown,
                County               = group.GroupCounty,
                Postcode             = group.GroupPostcode,
            };

            managementGroup.Type =
                await TranslateAsync(EnumerationNames.ManagementGroupType, group.GroupType, cancellationToken);

            managementGroup.Code = $"{managementGroup.Type}-{managementGroup.Identifier}";

            managementGroup.SetLineageForRequestedFields();
            return(managementGroup as TDestination);
        }