/// <summary> /// Adds new product to stock by utilizing service client. /// </summary> public void AddProduct() { bool isValidProductName = false; string productName; do { Console.WriteLine("Please enter product name:"); productName = Console.ReadLine(); if (ValidateForLetters(productName) == false) { Console.WriteLine("Product name can only contain letters and spaces."); } else { isValidProductName = true; } } while (isValidProductName == false); bool isValidAmount = false; string amountInStock; int amountNumber; do { Console.WriteLine("Please enter product stock amount:"); amountInStock = Console.ReadLine(); bool isNumber = int.TryParse(amountInStock, out amountNumber); if (isNumber == false || amountNumber < 1) { Console.WriteLine("Please enter a positive integer."); } else { isValidAmount = true; } } while (isValidAmount == false); bool isValidPrice = false; string priceString; double price; do { Console.WriteLine("Please enter product price:"); priceString = Console.ReadLine(); bool isDouble = double.TryParse(priceString, out price); if (isDouble == false || price <= 0.0) { Console.WriteLine("Please enter a positive price."); } else { isValidPrice = true; } } while (isValidPrice == false); Product product = new Product() { Name = productName, ItemsRemaining = amountNumber, Price = price }; using (ProductServiceClient wcf = new ProductServiceClient()) { wcf.AddNewProduct(product); } Console.WriteLine(); Console.WriteLine("New product added successfully."); }