private async Task <bool> UploadVehicles(Person person, SSG_SearchRequest request, SSG_Person ssg_person, int?providerDynamicsID, CancellationToken concellationToken)
        {
            if (person.Vehicles == null)
            {
                return(true);
            }
            try
            {
                foreach (var v in person.Vehicles)
                {
                    VehicleEntity vehicle = _mapper.Map <VehicleEntity>(v);
                    vehicle.SearchRequest     = request;
                    vehicle.InformationSource = providerDynamicsID;
                    vehicle.Person            = ssg_person;
                    SSG_Asset_Vehicle ssgVehicle = await _searchRequestService.CreateVehicle(vehicle, concellationToken);

                    if (v.Owners != null)
                    {
                        foreach (var owner in v.Owners)
                        {
                            SSG_AssetOwner assetOwner = _mapper.Map <SSG_AssetOwner>(owner);
                            assetOwner.Vehicle = ssgVehicle;
                            await _searchRequestService.CreateAssetOwner(assetOwner, concellationToken);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(false);
            }
        }
Exemple #2
0
        private async Task <bool> UploadVehicles()
        {
            if (_foundPerson.Vehicles == null)
            {
                return(true);
            }
            try
            {
                _logger.LogDebug($"Attempting to create vehicles records for SearchRequest[{_searchRequest.SearchRequestId}]");

                foreach (var v in _foundPerson.Vehicles)
                {
                    VehicleEntity vehicle = _mapper.Map <VehicleEntity>(v);
                    vehicle.SearchRequest     = _searchRequest;
                    vehicle.InformationSource = _providerDynamicsID;
                    vehicle.Person            = _returnedPerson;
                    SSG_Asset_Vehicle ssgVehicle = await _searchRequestService.CreateVehicle(vehicle, _cancellationToken);

                    if (v.Owners != null)
                    {
                        foreach (var owner in v.Owners)
                        {
                            AssetOwnerEntity assetOwner = _mapper.Map <AssetOwnerEntity>(owner);
                            assetOwner.Vehicle = ssgVehicle;
                            await _searchRequestService.CreateAssetOwner(assetOwner, _cancellationToken);
                        }
                    }
                    await CreateResultTransaction(ssgVehicle);
                }
                return(true);
            }
            catch (Exception ex)
            {
                LogException(ex);
                return(false);
            }
        }