/// <summary> /// Retrieve one order. /// </summary> public Order Retrieve(int orderId) { // Create the instance of the Order class // Pass in the requested Id Order order = new Order(orderId); // Code that retrieves the defined order return order; }
public void Add(Order order) { // -- Create the order for the customer. -- // For each item ordered, // Validate the entered information. // If not valid, notify the user. // If valid, // Open a connection // Set stored procedure parameters with the order data. // Call the save stored procedure. }
public void PlaceOrderTestNullCustomer() { // -- Arrange var orderController = new OrderController(); Customer customer = null; var order = new Order(); var payment = new Payment() { PaymentType = 1 }; // -- Actual OperationResult op = orderController.PlaceOrder(customer, order, payment, allowSplitOrders: true, emailReceipt: true); // -- Assertion }
public void OrderItems(Order order, bool allowSplitOrders) { //-- Order the items from inventory //For each item ordered, //Locate the item in inventory. //If no longer available, notify the user. //If any items are back ordered and //The customer does not want split orders, //Notify the user. //If the item is available, //Decrement the quantity remaining. //Open a connection //Set stored procedure parameters with the inventory data. //Call the save stored procedure. }
/// <summary> /// Retrieve one order. /// </summary> public Order Retrieve(int orderId) { // Create the instance of the Order class // Pass in the requested Id Order order = new Order(orderId); // Code that retrieves the defined order // Temporary hard coded values to return // a populated order if (orderId == 10) { order.OrderDate = new DateTimeOffset(2014, 4, 14, 10, 00, 00, new TimeSpan(7, 0, 0)); } return order; }
// // // public Order Retrieve(int orderId) { // // Order order = new Order(orderId); // // // if (orderId == 10) { order.OrderDate = new DateTimeOffset(2015, 7, 29, 10, 00, 00, new TimeSpan()); } return order; }
public void PlaceOrderTest() { // -- Arrange var orderController = new OrderController(); var customer = new Customer() { EmailAddress = "*****@*****.**" }; var order = new Order(); var payment = new Payment() { PaymentType = 1 }; // -- Actual OperationResult op = orderController.PlaceOrder(customer, order, payment, allowSplitOrders: true, emailReceipt: true); // -- Assertion Assert.AreEqual(true, op.Success); Assert.AreEqual(0, op.MessageList.Count); }
public Order Retrieve(int orderId) { //Create the instance of the Order Class //Pass in the requested Id Order order = new Order(); //Code that retrieves the defined Order //Temporary hard coded values to return //a poopulated order if (orderId == 10) { order.OrderData = new DateTimeOffset(); } return order; }
private void PlaceOrder() { var allowSplitOrders = true; var emailReceipt = true; var customer = new Customer(); // Populate the customer instance var order = new Order(); // Populate the order instance var payment = new Payment(); // Populate the payment info from the UI var orderController = new OrderController(); orderController.PlaceOrder(customer, order, payment, allowSplitOrders: false, emailReceipt: true); // allowSplitOrders: false, emailReceipt: true }
/// <summary> /// Saves the current order. /// </summary> /// <returns></returns> public bool Save(Order order) { var success = true; if (order.HasChanges && order.IsValid) { if (order.IsNew) { // Call an Insert Stored Procedure } else { // Call an Update Stored Procedure } } return success; }
public OperationResult PlaceOrder(Customer customer, Order order, Payment payment, bool allowSplitOrders, bool emailReceipt) { // This program makes assertions that certain functions are running (as functions below) // These will throw a warning during debuging if an assertion isn't true Debug.Assert(customerRepository != null, "Missing customer repository instance N***A"); Debug.Assert(orderRepository != null, "Missing order repository instance"); Debug.Assert(inventoryRepository != null, "Missing inventory repository instance"); Debug.Assert(emailLibrary != null, "Missing email library instance"); if (customer == null) throw new ArgumentNullException("Customer instance is null"); if (order == null) throw new ArgumentNullException("Order instance is null"); if (payment == null) throw new ArgumentNullException("Payment instance is null"); var op = new OperationResult(); customerRepository.Add(customer); orderRepository.Add(order); inventoryRepository.OrderItems(order, allowSplitOrders); payment.ProcessPayment(); if (emailReceipt) { var result = customer.ValidateEmail(); if (result.Success) { customerRepository.Update(); emailLibrary.SendEmail(customer.EmailAddress, "Here is your receipt"); } else { // log the messages if (result.MessageList.Any()) { op.AddMessage(result.MessageList[0]); } } } return op; }
public void PlaceOrder(Customer customer, Order order, Payment payment, bool allowSplitOrders, bool emailReceipt) { customerRepository.Add(customer); orderRepository.Add(order); inventoryRepository.OrderItems(order, allowSplitOrders); payment.ProcessPayment(); if (emailReceipt) { customer.ValidateEmail(); customerRepository.Update(); emailLibrary.SendEmail(customer.EmailAddress, "Here are your receipt!"); } }
public void PlaceOrder(Customer customer, Order order, Payment payment, bool allowSplitOrders, bool emailReceipt) // put objects in order put flags(bool values) at the end { customerRepository.Add(customer); orderRepository.Add(order); inventoryRepository.OrderItems(order, allowSplitOrders); payment.ProcessPayment(payment); if (emailReceipt) { customer.ValidateEmail(); customerRepository.Update(); emailLibrary.SendEmail(customer.EmailAddress, "Here is your receipt"); } }
public void OrderItems(Order order, bool v) { // Order the items from inventory }
public void PlaceOrderTestNullPayment() { // -- Arrange var orderController = new OrderController(); var customer = new Customer() { EmailAddress = "*****@*****.**" }; var order = new Order(); Payment payment = null; // -- Actual OperationResult op = orderController.PlaceOrder(customer, order, payment, allowSplitOrders: true, emailReceipt: true); // -- Assertion }
public void Add(Order order) { }
public void OrderItems(Order order, bool allowSplitOrders) { }