예제 #1
0
        public void UpdateListingQuantities(ERPContext context, string accountName, Dictionary <string, int> inventoryDictionary, Dictionary <string, Dictionary <string, int> > productCombineDictionary)
        {
            Dictionary <string, int> quantities = new Dictionary <string, int>();
            var q = from amazonList in context.AmazonList
                    where amazonList.AccountName == accountName
                    select amazonList;

            foreach (var row in q)
            {
                int  oldQuantity       = row.Quantity;
                int  warehouseQuantity = 0;
                int  newQuantity       = 0;
                bool update            = m_platformServiceFactory.GetInventoryService(m_company).GetNewQuantity(inventoryDictionary, productCombineDictionary, row.SKU, 1, oldQuantity, out warehouseQuantity, out newQuantity);
                m_logger.Info(accountName + ": " + row.SKU + " listing quantity: " + oldQuantity + " warehouse quantity: " + warehouseQuantity);
                if (update)
                {
                    quantities[row.SKU] = newQuantity;
                    row.Quantity        = newQuantity;
                    m_logger.Info(accountName + ": Quantity of " + row.SKU + " has been changed from " + oldQuantity + " to " + newQuantity);
                }
            }

            if (quantities.Count() > 0)
            {
                UpdateInventory(accountName, quantities);
                context.SaveChanges();
            }
        }
예제 #2
0
        public IActionResult GetInventories(string company, string sku)
        {
            List <Inventory>  inventories      = null;
            IInventoryService inventoryService = m_platformServiceFactory.GetInventoryService(company);

            if (inventoryService != null)
            {
                inventories = inventoryService.GetInventories(sku);
            }

            return(Ok(inventories));
        }