private async Task <int> DeleteWooAttributeVariety(WooProductAttributeTermMap deleteWooProductAttributeTermMap)
        {
            int _result = AppUnitOfWork.CONST_WASERROR;  // if all goes well this will be change to the number of records returned

            IWooProductAttributeTerm _wooProductAttributeTermRepository = await GetIWooProductAttributeTerm();

            if (_wooProductAttributeTermRepository != null)
            {
                int _parentAtributeId = await GetAttributeTermParentId();

                string _TempWooCat = await _wooProductAttributeTermRepository.DeleteProductAttributeTermByIdAsync(deleteWooProductAttributeTermMap.WooProductAttributeTermId, _parentAtributeId);

                _result = (String.IsNullOrEmpty(_TempWooCat)) ? AppUnitOfWork.CONST_WASERROR : 1;  // return the id
            }
            return(_result);
        }
        private async Task <ProductAttributeTerm> AddItemToWooOnlySync(ItemAttributeVarietyLookup addEntity)
        {
            IWooProductAttributeTerm _wooProductAttributeTermRepository = await GetIWooProductAttributeTerm();

            if (_wooProductAttributeTermRepository == null)
            {
                return(null);
            }

            ProductAttributeTerm _wooProductAttributeTerm = new ProductAttributeTerm
            {
                name = addEntity.VarietyName,
                //                 order_by = ConvertToWooOrderBy(addEntity.OrderBy),
            };
            int _parentAttributeId = await GetAttributeTermParentId();

            return(await _wooProductAttributeTermRepository.AddProductAttributeTermAsync(_wooProductAttributeTerm, _parentAttributeId));  // should return a new version with ID
        }
        public override async Task <int> UpdateWooItemAsync(ItemAttributeVarietyLookupView updateViewEntity)
        {
            int _result = 0;  /// null or not found

            if ((updateViewEntity.HasWooAttributeVarietyMap) && ((bool)(updateViewEntity.CanUpdateWooMap)))
            {
                IWooProductAttributeTerm _wooProductAttributeTermRepository = await GetIWooProductAttributeTerm();

                if (_wooProductAttributeTermRepository != null)                     //  - > if it does not exist then what?
                {
                    WooProductAttributeTermMap _updateWooMapEntity = await GetWooProductAttributeTermMapFromID(updateViewEntity.ItemAttributeVarietyLookupId);

                    if (_updateWooMapEntity == null)
                    {
                        // need to add the AttributeVariety -> this is done later.
                        _result = await AddWooItemAndMapAsync(updateViewEntity);
                    }
                    else
                    {
                        int _parentAttributeId = await GetAttributeTermParentId();

                        ProductAttributeTerm _wooProductAttributeTerm = await _wooProductAttributeTermRepository.GetProductAttributeTermByIdAsync(_updateWooMapEntity.WooProductAttributeTermId, _parentAttributeId);

                        if (_wooProductAttributeTerm == null)
                        {
                            return(AppUnitOfWork.CONST_WASERROR);  /// oops what happened >?
                        }
                        else
                        {
                            // only update if different
                            if (!_wooProductAttributeTerm.name.Equals(updateViewEntity.VarietyName))                           //|| (!_wooProductAttributeTerm.order_by.Equals(updateViewEntity.OrderBy.ToString(), StringComparison.OrdinalIgnoreCase)))
                            {
                                _wooProductAttributeTerm.name = updateViewEntity.VarietyName;                                  // only update if necessary
                                                                                                                               //_wooProductAttributeTerm.order_by = ConvertToWooOrderBy(updateViewEntity.OrderBy);
                                var _res = ((await _wooProductAttributeTermRepository.UpdateProductAttributeTermAsync(_wooProductAttributeTerm, _parentAttributeId)));
                                _result = ((_res == null) || (_res.id == null)) ? AppUnitOfWork.CONST_WASERROR : (int)_res.id; // if null there is an issue
                            }
                        }
                    }
                }
            }
            return(_result);
        }