/// <summary> /// does the building of an order through user input and saves to DB /// </summary> /// <param name="baseRepo"> dbcontext point</param> /// <param name="storeLocation"> store location that is originally created from StoreMenuInput switch returns </param> /// <param name="userName"> user's username that is originally created from the SignInUser method </param> public void OrderInput(BaseRepo baseRepo, int storeLocation, string userName) { int maxProductTypes = 3; int maxProductAmount = 100; Order placedOrder = new Order(); placedOrder.CustomerId = baseRepo.GetCustomerIDByName(userName); placedOrder.StoreId = storeLocation; Console.WriteLine("Please select a number for which item you wish to purchase"); Console.WriteLine(" 1: Apple ($0.80 each)\n2: Orange ($1.00 each)\n3: Banana ($0.30 each"); string productInput = Console.ReadLine(); while (productInput.Any(char.IsLetter) || int.Parse(productInput) < 0 || int.Parse(productInput) > maxProductTypes) { Console.WriteLine("\nPlease insert a valid number choice"); productInput = Console.ReadLine(); } int productSelect = int.Parse(productInput); placedOrder.ProductId = productSelect; placedOrder.ItemName = baseRepo.GetItemNameByProductID(placedOrder.ProductId); Console.WriteLine("Please select a quantity for the item selected."); string pQuantityInput = Console.ReadLine(); while (pQuantityInput.Any(char.IsLetter) || int.Parse(pQuantityInput) < 0 || int.Parse(pQuantityInput) > maxProductAmount) { Console.WriteLine("\nPlease insert a valid number choice"); pQuantityInput = Console.ReadLine(); } int pQuantitySelect = int.Parse(pQuantityInput); placedOrder.ProductQuantity = pQuantitySelect; baseRepo.AddOrder(placedOrder); baseRepo.Save(); }
public void AddNewOrder(BestEats.Logic.Order order) { _orderRepo.AddOrder(order); }