Ejemplo n.º 1
0
        //Adds a new stock order item to the stock order item table-Grace
        public bool AddNewStockOrderItem(int itemID, int quantity, double total, int orderID)
        {
            try
            {
                StockOrderItemList = DataLayer.getAllStockOrderItems();
                int maxId = 0;

                foreach (StockOrderItem item in StockOrderItemList)
                {
                    if (item.OrderItemID > maxId)
                    {
                        maxId = item.OrderItemID;
                    }
                }

                IStockOrderItem theItem = StockOrderItemFactory.GetOrderItem(maxId + 1, itemID, quantity, total, orderID);
                // Using a Factory to create the user entity object. ie seperating object creation from business logic
                _stockOrderItemList.Add(theItem);            // Add a reference to the newly created object to the Models UserList
                DataLayer.AddNewStockOrderItemToDB(theItem); //Gets the DataLayer to add the new user to the DB.
                return(true);
            }
            catch (System.Exception excep)
            {
                return(false);
            }
        }