Example #1
0
        public virtual async Task <bool> WooIsActiveAsync(ApplicationState currentApplicatioonState)
        {
            if (!currentApplicatioonState.HaveCheckState)
            {
                try
                {
                    WooAPISettings _wooAPISettings = await GetWooAPISettingsAsync();

                    if (_wooAPISettings == null)
                    {
                        currentApplicatioonState.SetWooIsActive(false);
                    }
                    else
                    {
                        WooProductCategory _wooProductCategory = new WooProductCategory(_wooAPISettings, _Logger);
                        if (_wooProductCategory == null)
                        {
                            currentApplicatioonState.SetWooIsActive(false);
                        }
                        else
                        {
                            currentApplicatioonState.SetWooIsActive(await _wooProductCategory.CheckProductCategoryLinkAsync());
                        }
                    }
                }
                catch (Exception ex)
                {
                    _Logger.LogError($"Error running async tasks: {ex.Message}");
                    throw;
                }
            }

            return(currentApplicatioonState.WooIsActive);
        }
        /// <summary>
        /// All the category import stuff. Could we have generalised this?
        /// </summary>

        /* Objective:
         *
         *  We create a list of item categories. From that list we need to create a list of primary categories. These are used in the items mapping. Only those that are imported can be used
         *  Mapping:
         *
         *  The Table WooCategoryMaps stores the category information.
         *
         *  Field	                                UsedFor
         *  WooCategoryID [int]	                    To store the CategoryID  that Woo returns
         *  WooCategoryName [string (size:2-255)]	To store Categories.name that Woo returns
         *  WooCategorySlug [string (size:2-255)]	To store Categories.slug that Woo returns
         *  WooCategoryParentID	                    Can be null if not will point to a WooCategoryID
         *  ItemCategoryLookupID	                        This links to the Category in the system. Allows us to transfer the data.
         *
         *  Item categories Should be linked to tracking so items in similar categories are tracked similarly.
         */
        // Retrieve data from Woo
        public async Task <List <ProductCategory> > GetWooCategoryData()
        {
            WooAPISettings _wooAPISettings = new WooAPISettings(AppWooSettings);


            IWooProductCategory _WooProductCategory = new WooProductCategory(_wooAPISettings, _Logger);

            //List<ProductCategory> wooProductCategories = await _WooProductCategory.GetAllProductCategories();
            return(await _WooProductCategory.GetAllProductCategoriesAsync());

            //return wooProductCategories;
        }