private static void PromptAddOrder() { string customerName = ""; string state = ""; ProductType productType = null; decimal area = 0M; while (string.IsNullOrEmpty(customerName)) { OffsetTop(); Console.ForegroundColor = PromptColor; Console.Write("\tEnter the customer name: "); Console.ForegroundColor = EmphasisColor; customerName = Console.ReadLine(); Console.ResetColor(); Console.Clear(); } state = PromptForValidState("Enter the customer state: ", true); productType = PromptForValidProductType("Enter the product type: ", true); area = PromptForValidArea(productType, true); Order orderToAdd = new Order() { CustomerName = customerName, State = state, ProductType = productType.Type, Area = area }; //calculate remaining fields and assign order number orderToAdd = OrderOperations.CalculateRemainingOrderFields(orderToAdd); orderToAdd = OrderOperations.AssignOrderNumber(orderToAdd); if (PromptConfirmOrder(orderToAdd, "Would you like to add the order? ")) { OrderOperations.AddOrder(orderToAdd); Console.Clear(); DisplayOrder(orderToAdd); Console.ForegroundColor = SuccessColor; Console.WriteLine("\tOrder added successfully."); Console.WriteLine(); PressEnterToContinueToMain(); } else { Console.Clear(); orderToAdd = EditOrder(orderToAdd); //TODO: Check what happens if an error occurs during edit? if (orderToAdd != null) //if it's null, they chose to cancel and return to the main menu { OrderOperations.AddOrder(orderToAdd); DisplayOrder(orderToAdd); Console.ForegroundColor = SuccessColor; Console.WriteLine("\tOrder added successfully."); PressEnterToContinueToMain(); } Console.Clear(); } }
public void AssignOrderNumberTest() { Order order = new Order(); order.Date = new DateTime(2013, 06, 01); order = OrderOperations.AssignOrderNumber(order); int numberOfOrders = OrderOperations.GetOrdersByDate(new DateTime(2013, 06, 01)).Count; Assert.AreEqual(order.Number, numberOfOrders + 1); }