public ProductOperations(IProductView view, DataAccessProduct productData) { this.view = view; this.productData = productData; var products = productData.RetrieveProduct(); this.view.LoadProduct(products); view.Add += () => { var p = view.AddProduct(); productData.AddProduct(p); }; view.Updatee += () => { var p = view.UpdateProduct(); productData.UpdateProduct(p); }; view.Deletee += () => { var p = view.DeleteProduct(); productData.DeleteProduct(p); }; view.Ret += () => { products = productData.RetrieveProduct(); this.view.LoadProduct(products); }; }
private void ProductCommands(string input) { if (input.Contains(Add)) { _productView.AddProduct(); } if (input.Contains(Update)) { _productView.UpdateProduct(); } if (input.Contains(Delete)) { _productView.DeleteProduct(); } if (input.Contains(One)) { _productView.GetProduct(); } if (input.Contains(All)) { _productView.GetProducts(); } if (input.Contains(Search)) { _productView.SearchProducts(); } if (input.Contains(AddPerson)) { _productView.AddPerson(); } if (input.Contains(RemovePerson)) { _productView.RemovePerson(); } }
public void ShowMainMenu() { int choice = 0; while (true) { Console.WriteLine("1. Show All Product"); Console.WriteLine("2. View Single Product"); Console.WriteLine("3. Create Product"); Console.WriteLine("4. Update Product Info"); Console.WriteLine("5. Delete Product"); Console.WriteLine("6. Show All Wish List"); Console.WriteLine("7. View Single Wish List"); Console.WriteLine("8. Create Wish List"); Console.WriteLine("9. Update Wish List"); Console.WriteLine("10. Delete Wish List"); Console.WriteLine("11. Show All Coupons"); Console.WriteLine("12. Show Wish List Price"); Console.WriteLine("Any other key to exit."); Console.WriteLine("Enter your choice (1-12): "); choice = Helper.ReadSafeInt(); if (!(choice >= 1 && choice <= 12)) { Console.WriteLine("Thank you very much."); Console.ReadKey(); break; } { IProductView productsView = null; IWishView wishView = null; using (var scope = DependencyResolver.Instance().BeginLifetimeScope()) { wishView = scope.Resolve <IWishView>(); productsView = scope.Resolve <IProductView>(); } switch (choice) { case 1: productsView.ShowAllProductsView(); break; case 2: productsView.ViewSingleProduct(); break; case 3: productsView.CreateProduct(); break; case 4: productsView.UpdateProduct(); break; case 5: productsView.DeleteProduct(); break; case 6: wishView.ShowAllWish(); break; case 7: wishView.ViewSingleWish(); break; case 8: wishView.CreateWish(); break; case 9: wishView.UpdateWish(); break; case 10: wishView.DeleteWish(); break; case 11: wishView.ShowAllCoupons(); break; case 12: wishView.ShowWishListPrice(); break; default: break; } } Console.WriteLine($"Entered Value {choice}"); } }