async Task <Guid> ImportAndMapAttributeTermData(ProductAttributeTerm sourcePAT, Guid sourceParentAttributeId)
        {
            Guid _itemAttributeTermId = Guid.Empty;
            // Get repository for each database we are accessing. ItemAttributeTerm. WooProductAttributeTermMap & WooSyncLog
            IAppRepository <WooProductAttributeTermMap> _wooAttributeTermMapRepository = _AppUnitOfWork.Repository <WooProductAttributeTermMap>();

            // Import the AttributeTerm and set sync data
            ///first check if it exists in the mapping, just in case there has been a name change
            WooProductAttributeTermMap _wooAttributeTermMap = await _wooAttributeTermMapRepository.FindFirstAsync(wa => wa.WooProductAttributeTermId == sourcePAT.id);

            if (_wooAttributeTermMap != null)   // the id exists so update
            {
                _itemAttributeTermId = await UpdateProductAttributeTerm(sourcePAT, sourceParentAttributeId, _wooAttributeTermMap);

                currImportCounters.TotalUpdated++;
            }
            else      // the id does not exists so add
            {
                _itemAttributeTermId = await AddProductAttributeTerm(sourcePAT, sourceParentAttributeId, _wooAttributeTermMap);

                currImportCounters.TotalAdded++;
            }

            return(_itemAttributeTermId);
        }
        async Task <Guid> AddProductAttributeTerm(ProductAttributeTerm sourcePAT, Guid sourceParentAttributeId, WooProductAttributeTermMap sourceWooAttributeTermMapsourceParentAttributeId)
        {
            Guid _itemAttributeTermId = Guid.Empty;
            IAppRepository <WooProductAttributeTermMap> _wooAttributeTermMapRepository = _AppUnitOfWork.Repository <WooProductAttributeTermMap>();

            // Add Item AttributeTerm if it does not exist
            _itemAttributeTermId = await AddOrGetIDItemAttributeVariety(sourcePAT, sourceParentAttributeId);

            if (sourceWooAttributeTermMapsourceParentAttributeId == null)
            {
                sourceWooAttributeTermMapsourceParentAttributeId = new WooProductAttributeTermMap
                {
                    WooProductAttributeTermId    = (int)sourcePAT.id,
                    ItemAttributeVarietyLookupId = _itemAttributeTermId
                };
            }
            else
            {
                sourceWooAttributeTermMapsourceParentAttributeId.WooProductAttributeTermId    = (int)sourcePAT.id;
                sourceWooAttributeTermMapsourceParentAttributeId.ItemAttributeVarietyLookupId = _itemAttributeTermId;
            }
            if (await _wooAttributeTermMapRepository.AddAsync(sourceWooAttributeTermMapsourceParentAttributeId) == AppUnitOfWork.CONST_WASERROR)
            {
                // did not add so set _ItemAttributeTermId to ItemAttributeTermID to Guid.Empty = error
                _itemAttributeTermId = Guid.Empty;
            }
            return(_itemAttributeTermId);
        }
        async Task <Guid> UpdateProductAttributeTerm(ProductAttributeTerm sourcePAT, Guid sourceParentAttributeId, WooProductAttributeTermMap sourceWooAttributeTermMap)
        {
            // we have found a mapping between the woo Product AttributeTerm and our AttributeTerm id so update the Attribute table just in case.
            Guid _itemAttributeTermId = Guid.Empty;
            IAppRepository <WooProductAttributeTermMap> _wooProductAttributeTermMapRepository = _AppUnitOfWork.Repository <WooProductAttributeTermMap>();

            _itemAttributeTermId = await AddOrUpdateItemAttributeVariety(sourcePAT, sourceParentAttributeId, sourceWooAttributeTermMap.ItemAttributeVarietyLookupId);

            /// Now update the woo AttributeTerm using the _ItemAttributeTermId returned.
            if (await _wooProductAttributeTermMapRepository.UpdateAsync(sourceWooAttributeTermMap) == AppUnitOfWork.CONST_WASERROR)
            {   // did not updated so set _ItemAttributeTermId to ItemAttributeTermID to Guid.Empty = error
                _itemAttributeTermId = Guid.Empty;
            }

            return(_itemAttributeTermId);
        }