public List <ProductObject> GetAllProduct() { ProductOperation po = new ProductOperation(); return(po.GetAllProduct()); }
public static void ProductOperationMenu() { Console.WriteLine("Please Select Product Operation"); Console.WriteLine("a. Add a Product"); Console.WriteLine("b. List all Products"); Console.WriteLine("c. Search a Product"); Console.WriteLine("d. Delete a Product"); Console.WriteLine("e. Main Menu"); char ch1 = Convert.ToChar(Console.ReadLine()); switch (ch1) { case 'a': Console.WriteLine("Enter Product Name"); var ProductName = Console.ReadLine(); while (string.IsNullOrWhiteSpace(ProductName) || int.TryParse(ProductName, out _)) { Console.WriteLine("Please Enter Only Char and It can not be Empty"); ProductName = Console.ReadLine(); } Console.WriteLine("Enter Short Code"); var shortCode = Console.ReadLine(); Console.WriteLine("Enter Description"); var desc = Console.ReadLine(); while (string.IsNullOrWhiteSpace(desc) || int.TryParse(desc, out _)) { Console.WriteLine("Please Enter Only Char and It can not be Empty"); desc = Console.ReadLine(); } Console.WriteLine("Enter Price"); int price = -1; bool flag = Int32.TryParse(Console.ReadLine(), out price); while (!flag || price <= 0) { Console.WriteLine("Please Enter Only Number and It can not be Empty/can not be negetive"); flag = Int32.TryParse(Console.ReadLine(), out price); } Console.WriteLine("Enter Manufacture Name"); var manufactureName = Console.ReadLine(); while (string.IsNullOrWhiteSpace(manufactureName) || int.TryParse(manufactureName, out _)) { Console.WriteLine("Please Enter Only Char and It can not be Empty"); manufactureName = Console.ReadLine(); } Console.WriteLine("Enter Category Name"); var category = Console.ReadLine(); while (string.IsNullOrWhiteSpace(category) || int.TryParse(category, out _)) { Console.WriteLine("Please Enter Only Char and It can not be Empty"); category = Console.ReadLine(); } ProductOperation.AddProduct(ProductName, shortCode, desc, price, manufactureName, category); break; case 'b': ProductOperation.GetAllProduct(); break; case 'c': Console.WriteLine("Enter Product Name"); var SearchProductName = Console.ReadLine(); while (string.IsNullOrWhiteSpace(SearchProductName) || int.TryParse(SearchProductName, out _)) { Console.WriteLine("Please Enter Only Char and It can not be Empty"); ProductName = Console.ReadLine(); } ProductOperation.SearchProduct(SearchProductName); break; case 'd': Console.WriteLine("Enter Product Name"); var DeleteProductName = Console.ReadLine(); while (string.IsNullOrWhiteSpace(DeleteProductName) || int.TryParse(DeleteProductName, out _)) { Console.WriteLine("Please Enter Only Char and It can not be Empty"); DeleteProductName = Console.ReadLine(); } ProductOperation.DeleteProduct(DeleteProductName); break; case 'e': StartMenu.Menu(); break; default: Console.WriteLine("Invalid Selection!!"); ProductOperationMenu(); break; } }