//Adds a new stock order to the database-Grace public bool AddNewStockOrder(DateTime orderCreated, int supplierID, string deliverTo, double orderTotal, string status) { try { StockOrderList = DataLayer.getAllOrders(); int maxId = 0; foreach (StockOrder order in StockOrderList) { if (order.orderID > maxId) { maxId = order.orderID; } } IStockOrder theOrder = StockOrderFactory.GetStockOrder(maxId + 1, orderCreated, supplierID, deliverTo, orderTotal, status); // Using a Factory to create the user entity object. ie seperating object creation from business logic _stockOrderList.Add(theOrder); // Add a reference to the newly created object to the Models UserList DataLayer.AddNewStockOrderToDB(theOrder); //Gets the DataLayer to add the new user to the DB. return(true); } catch (System.Exception excep) { return(false); } }
public Boolean addnewStockOrder(int stockOrderID, int UserID, string date) { try { IStockOrder aStockOrder = StockOrderFactory.GetStockOrder(stockOrderID, UserID, date); // Using a Factory to create the user entity object. ie seperating object creation from business logic StockOrderList.Add(aStockOrder); // Add a reference to the newly created object to the Models UserList DataLayer.addNewStockOrderToDB(aStockOrder); //Gets the DataLayer to add the new user to the DB. return(true); } catch (System.Exception excep) { return(false); } }