コード例 #1
0
        public async Task TestGetInventory()
        {
            var inventory = await _client.GetInventory <InventoryItem>();

            Assert.IsNotNull(inventory);
            Assert.IsTrue(inventory.Items.ToList().Count > 0);
        }
コード例 #2
0
        public async Task LoadSessionData()
        {
            try
            {
                this.Inventory = await _qbClient
                    .GetInventory<InventoryItem>()
                    .ConfigureAwait(false);

                this.PriceLevels = await _qbClient
                    .GetPriceLevels<PriceLevel>()
                    .ConfigureAwait(false);

                this.CleanItems();

                var electricianMap = PriceLevels.Items.First(item => item.Name.ToLower().Equals("electrician")).PriceLevelItems.Select(
                                                             item => new { item.ItemRef.Name, item.CustomPrice }).ToDictionary(
                                                             item => item.Name, item => item.CustomPrice);

                var contractorMap = PriceLevels.Items.First(item => item.Name.ToLower().Equals("contractor")).PriceLevelItems.Select(
                                                            item => new { item.ItemRef.Name, item.CustomPrice }).ToDictionary(
                                                            item => item.Name, item => item.CustomPrice);

                foreach (var item in Inventory.Items)
                {

                    electricianMap.TryGetValue(item.Code, out double price);
                    item.ElectricianPrice = price;

                    contractorMap.TryGetValue(item.Code, out price);
                    item.ContractorPrice = price;
                }

                _log.Debug("Inventory session data has been loaded");
            }
            catch (Exception ex)
            {
                throw new QuickBooksClientException(ex.ToString());
            }
        }