public void RunTransfer()
        {
            header = AdalAuthenticate();
            var start = DateTime.Now;

            DataWriter.TruncateTables(true, false, false, true, true, false);
            var truncate = DateTime.Now;

            Debug.WriteLine("Truncate = " + truncate.Subtract(start).TotalSeconds);
            ItemCategoryTransfer.WriteCategories(header);
            DateTime cat = DateTime.Now;

            Debug.WriteLine("Category = " + cat.Subtract(truncate).TotalSeconds);
            LocationsAndVendorsTransfer.WriteLocationsAndVendors(context, header);
            DateTime loc = DateTime.Now;

            Debug.WriteLine("Locations = " + loc.Subtract(cat).TotalSeconds);
            ItemTransfer.WriteItems(context, header);
            DateTime items = DateTime.Now;

            Debug.WriteLine("Items = " + items.Subtract(loc).TotalSeconds);
            ItemAttributeLookup.ReadItemAttributes(context, header);
            DateTime lookup = DateTime.Now;

            Debug.WriteLine("Lookup = " + lookup.Subtract(items).TotalSeconds);
        }
        async Task <Guid> UpdateItemAttribute(ProductAttribute pPA, ItemAttributeLookup pItemAttribute)
        {
            IAppRepository <ItemAttributeLookup> _ItemAttributeRepository = _AppUnitOfWork.Repository <ItemAttributeLookup>();

            pItemAttribute.AttributeName = pPA.name;
            pItemAttribute.Notes         = $"Updated Woo Attribute ID {pPA.id}";
            return((await _ItemAttributeRepository.UpdateAsync(pItemAttribute) != AppUnitOfWork.CONST_WASERROR) ? pItemAttribute.ItemAttributeLookupId : Guid.Empty);  // there was an error updating
        }
        async Task <Guid> AddOrUpdateItemAttribute(ProductAttribute pPA, Guid pWooMappedItemAttributeId)
        {
            Guid _ItemAttributeId = Guid.Empty;
            IAppRepository <ItemAttributeLookup> _ItemAttributeRepository = _AppUnitOfWork.Repository <ItemAttributeLookup>();
            // check if the Attribute exists
            ItemAttributeLookup _ItemAttribute = await _ItemAttributeRepository.FindFirstAsync(ic => ic.ItemAttributeLookupId == pWooMappedItemAttributeId);

            if (_ItemAttribute != null)
            {
                _ItemAttributeId = await UpdateItemAttribute(pPA, _ItemAttribute);
            }
            else
            {
                _ItemAttributeId = await AddOrGetIDItemAttribute(pPA);
            }
            return(_ItemAttributeId);
        }
        async Task <Guid> AddOrGetIDItemAttribute(ProductAttribute pPA)
        {
            IAppRepository <ItemAttributeLookup> _ItemAttributeRepository = _AppUnitOfWork.Repository <ItemAttributeLookup>();

            ItemAttributeLookup _ItemAttribute = await _ItemAttributeRepository.FindFirstAsync(ic => ic.AttributeName == pPA.name);

            if (_ItemAttribute == null)
            {
                ItemAttributeLookup _newItemAttribute = new ItemAttributeLookup
                {
                    AttributeName = pPA.name,
                    Notes         = $"Imported Woo Attribute ID {pPA.id}"
                };

                return((await _ItemAttributeRepository.AddAsync(_newItemAttribute) != AppUnitOfWork.CONST_WASERROR) ? _newItemAttribute.ItemAttributeLookupId : Guid.Empty);
            }
            else
            {
                return(_ItemAttribute.ItemAttributeLookupId);   // we found one with the same name so assume this is the correct one.
            }
        }