Esempio n. 1
0
        public static Result SaveInventoryProduct(OETLib.BusinessObjects.Model.Product Product, int productid)
        {
            Result webRes = new Result(false);

            try
            {
                //new inventory entry
                var inventoryToSave = new OETLib.BusinessObjects.Model.Inventory();
                inventoryToSave.ProductID                = productid;
                inventoryToSave.InventoryQuantity        = Product.InventoryQuantity;
                inventoryToSave.CurrentInventoryQuantity = Product.CurrentInventoryQuantity + Product.InventoryQuantity;
                inventoryToSave.InventoryItemCost        = Product.ItemCost;
                inventoryToSave.InventoryTypeID          = 1;

                var SavedInventory = inventoryToSave.TrySave(typeof(OETLib.BusinessObjects.Model.InventoryList));
                //Get the newly created inventory ID
                var newInventoryItem = new OETLib.BusinessObjects.Model.Inventory();
                newInventoryItem = OETLib.BusinessObjects.Model.InventoryList.GetInventoryList().LastOrDefault(d => d.ProductID == productid);
                //webRes.Data = newInventoryItem;//.InventoryID ;
                OETLib.BusinessObjects.Model.InventoryList inventoryList = OETLib.BusinessObjects.Model.InventoryList.GetInventoryList();
                inventoryList.Add(newInventoryItem);
                OETLib.BusinessObjects.Model.EditInventoryList editInventoryList = OETLib.BusinessObjects.Model.EditInventoryList.GetEditInventoryList();
                webRes.Data    = editInventoryList;
                webRes.Success = true;
            }
            catch (Exception e)
            {
                webRes.ErrorText = e.Message;
            }
            return(webRes);
        }
Esempio n. 2
0
        public Result SaveInventoryItem(OETLib.BusinessObjects.Model.EditInventory item)
        {
            Result webRes = new Result(false);

            try
            {
                var inventoryToSave = new OETLib.BusinessObjects.Model.Inventory();
                inventoryToSave.ProductID = item.ProductID;
                if (item.AddStatus == true)
                {
                    inventoryToSave.InventoryQuantity        = item.InventoryAmount;
                    inventoryToSave.CurrentInventoryQuantity = item.CurrentInventoryQuantity + item.InventoryAmount;
                    inventoryToSave.InventoryTypeID          = 1;
                }
                else
                {
                    inventoryToSave.InventoryQuantity        = -item.InventoryAmount;
                    inventoryToSave.CurrentInventoryQuantity = item.CurrentInventoryQuantity - item.InventoryAmount;
                    inventoryToSave.InventoryTypeID          = 3;
                }
                inventoryToSave.InventoryItemCost = item.InventoryItemCost;
                inventoryToSave.OrderID           = null;

                var SavedInventory     = inventoryToSave.TrySave(typeof(OETLib.BusinessObjects.Model.InventoryList));
                var newInventoryRecord = new OETLib.BusinessObjects.Model.Inventory();

                OETLib.BusinessObjects.Model.InventoryList InventoryList = OETLib.BusinessObjects.Model.InventoryList.GetInventoryList();
                InventoryList.Add(inventoryToSave);
                OETLib.BusinessObjects.Model.EditInventoryList editInventoryList = OETLib.BusinessObjects.Model.EditInventoryList.GetEditInventoryList();
                webRes.Success = true;
                webRes.Data    = editInventoryList;
            }
            catch (Exception ex)
            {
                return(new Result {
                    Success = false, ErrorText = ex.Message
                });
            }
            return(webRes);
        }