private Product InputBrandNewProduct() { string newName = UserRequestUtility.QueryProductName(); // TODO: Allow prices to be decimal numbers with two decimal points. More validation. Console.WriteLine("Enter a valid whole number price. We don't do that round-up 59.99 garbage here."); double newPrice = UserRequestUtility.QueryQuantity(); ProductType newType = ProductType.Water; List <string> possibleTypes = new List <string>(); foreach (string type in Enum.GetNames(typeof(ProductType))) { possibleTypes.Add(type); } UserResponseUtility.DisplayPossibleChoicesToUser("What type of suffering is this suffering?", possibleTypes); int selectedType = UserRequestUtility.ProcessUserInputAgainstPossibleChoices(possibleTypes); foreach (int type in Enum.GetValues(typeof(ProductType))) { if (selectedType == type) { string newTypeAsString = Enum.GetNames(typeof(ProductType))[type]; newType = Enum.Parse <ProductType>(newTypeAsString); } } string newDescription = UserRequestUtility.QueryDescription(); return(new Product(newName, newPrice, newType, newDescription)); }
public override void ExecuteUserChoice() { int selectedQuantityDelta = selectedLineItem.ProductQuantity; switch (selectedChoice) { case 1: Console.WriteLine($"How much {selectedLineItem.Product.Name} would you like to add to stock?"); selectedQuantityDelta = UserRequestUtility.QueryQuantity(); selectedLineItem.ProductQuantity += selectedQuantityDelta; break; case 2: Console.WriteLine($"How much {selectedLineItem.Product.Name} would you like to remove from stock?"); selectedQuantityDelta = UserRequestUtility.QueryQuantity(); while (selectedQuantityDelta > selectedLineItem.ProductQuantity) { Console.WriteLine("You probably shouldn't remove more stock than we have. Might create a black hole. \n Try again."); selectedQuantityDelta = UserRequestUtility.QueryQuantity(); } selectedLineItem.ProductQuantity -= selectedQuantityDelta; // This code is now unnecessary and is handled by LocationService. //if (selectedLineItem.ProductQuantity <= 0) //{ // LocationService.RemoveInventoryLineItemInRepo(selectedLineItem); //} break; case 3: // No need to queue another menu because the preceding menu will run again. Console.WriteLine("Going back..."); return; } }