public async void CheckWooStatus() { Waiting = true; StateHasChanged(); WooAPISettings _WooAPISettings = new WooAPISettings(WooSettingsModel); //{ // ConsumerKey = WooSettingsModel.ConsumerKey, // ConsumerSecret = WooSettingsModel.ConsumerSecret, // QueryURL = WooSettingsModel.QueryURL, // IsSecureURL = WooSettingsModel.IsSecureURL, // JSONAPIPostFix = WooSettingsModel.JSONAPIPostFix, // RootAPIPostFix = WooSettingsModel.RootAPIPostFix //}; WooProduct _WooProducts = new WooProduct(_WooAPISettings, Logger); //int _count = await Task.Run(() => _WooProducts.GetProductCount()); //CheckProductLink()) //WooStatus = ((_count > 0) ? $"Success - product count: {_count}" : "Failed"); bool _success = await Task.Run(() => _WooProducts.CheckProductLink()); // GetProductCount()); // WooStatus = (_success ? $"Success" : "Failed"); Waiting = false; StateHasChanged(); ShowModalStatus.UpdateModalMessage($"Woo API call status: {Environment.NewLine}{Environment.NewLine} {WooStatus}"); ShowModalStatus.ShowModal(); }
public Product(WooProduct product, IEnumerable <WooVariant> variants) { ProductId = product.Id; Name = product.Name; Price = ConvertToNullDouble(product.Price); InventoryLevel = product.Stock_Quantity; Weight = ConvertToNullDouble(product.Weight); Variations = new Variation(); var attributes = variants.SelectMany(x => x.Attributes); Variations.Color = attributes.Where(x => x.Name.Equals("Color")).Select(x => x.Option); Variations.Size = attributes.Where(x => x.Name.Equals("Size")).Select(x => x.Option); }
/// <summary> /// All the attribute term import stuff. Attributes Terms in Woo are Attributed Varieties to us. Could we have generalised this for each item import with an object? /// </summary> #region AttrbiuteStuff // Retrieve data from Woo async Task <List <Product> > GetAllWooProducts(bool OnlyItemsInStock) { WooAPISettings _wooAPISettings = new WooAPISettings(AppWooSettings); WooProduct _wooProduct = new WooProduct(_wooAPISettings, _Logger); List <Product> wooProducts = OnlyItemsInStock ? await _wooProduct.GetAllProductsInStock() : await _wooProduct.GetAllProducts(); // unique check not needed // var _wooProducts = wooProducts.GroupBy(wp => wp.id).Select(wp => wp.FirstOrDefault()); // wooProducts that are distinct; // wooProducts = _wooProducts.ToList(); return(wooProducts); }