Example #1
0
        private async Task <int> DeleteWooAttribute(WooProductAttributeMap deleteWooProductAttributeMap)
        {
            int _result = AppUnitOfWork.CONST_WASERROR;  // if all goes well this will be change to the number of records returned

            IWooProductAttribute _wooProductAttributeRepository = await GetIWooProductAttribute();

            if (_wooProductAttributeRepository != null)
            {
                ProductAttribute _TempWooCat = await _wooProductAttributeRepository.DeleteProductAttributeByIdAsync(deleteWooProductAttributeMap.WooProductAttributeId);

                _result = (_TempWooCat == null) ? AppUnitOfWork.CONST_WASERROR : Convert.ToInt32(_TempWooCat.id);  // return the id
            }
            return(_result);
        }
Example #2
0
        //string _wooOrderBy = "menu_order";
        //switch (v.ToLower())
        //{
        //    case "id":   // OrderBys.Id.ToString().ToLower():
        //        _wooOrderBy = "id";
        //        break;
        //    case "name":  //OrderBys.Name
        //        _wooOrderBy = "name";
        //        break;

        //    case "number":  //OrderBys.Number
        //        _wooOrderBy = "name_num";
        //        break;

        //    default:
        //        break;
        //}
        //return _wooOrderBy;
        private async Task <ProductAttribute> AddItemToWooOnlySync(ItemAttributeLookup addEntity)
        {
            IWooProductAttribute _wooProductAttributeRepository = await GetIWooProductAttribute();

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

            ProductAttribute _wooProductAttribute = new ProductAttribute
            {
                name     = addEntity.AttributeName,
                order_by = ConvertToWooOrderBy(addEntity.OrderBy),
            };

            return(await _wooProductAttributeRepository.AddProductAttributeAsync(_wooProductAttribute));  // should return a new version with ID
        }
Example #3
0
        public override async Task <int> UpdateWooItemAsync(ItemAttributeLookupView updateViewEntity)
        {
            int _result = 0;  /// null or not found

            if ((updateViewEntity.HasWooAttributeMap) && ((bool)(updateViewEntity.CanUpdateWooMap)))
            {
                IWooProductAttribute _wooProductAttributeRepository = await GetIWooProductAttribute();

                if (_wooProductAttributeRepository != null)                     //  - > if it does not exist then what?
                {
                    WooProductAttributeMap _updateWooMapEntity = await GetWooProductAttributeMapFromID(updateViewEntity.ItemAttributeLookupId);

                    if (_updateWooMapEntity == null)
                    {
                        // need to add the Attribute -> this is done later.
                        _result = await AddWooItemAndMapAsync(updateViewEntity);
                    }
                    else
                    {
                        ProductAttribute _wooProductAttribute = await _wooProductAttributeRepository.GetProductAttributeByIdAsync(_updateWooMapEntity.WooProductAttributeId);

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