Example #1
0
File: Shop.cs Project: blinea/Oreo
        public static void LaunchShopMenu(string user)
        {
            bool start  = true;
            int  option = (int)Options.Default;

            do
            {
                ShowMenu(user);
                try
                {
                    option = int.Parse(Console.ReadLine());
                }
                catch (Exception)
                {
                    Alert.ShowAlert("Invalid Option", ConsoleColor.Red);
                }
                switch (option)
                {
                case (int)Options.Add:
                    Banner.ShowBanner("Add to Shopping Cart");
                    ProductCtrl.ReadAllProducts();
                    ShopCtrl.GetProduct(Product.GetId().Id, user);
                    Alert.Confirmation();
                    break;

                case (int)Options.Remove:
                    Banner.ShowBanner("Remove from Shopping Cart");
                    ShopCtrl.ShowShoppingCart();
                    ShopCtrl.RemoveProduct(Product.GetId().Id);
                    Alert.Confirmation();
                    break;

                case (int)Options.Cart:
                    Banner.ShowBanner("          Your Shopping Cart          ");
                    ShopCtrl.ShowShoppingCart();
                    Alert.Confirmation();
                    break;

                case (int)Options.Finish:
                    Banner.ShowBanner("          Your Order is Finished          ");
                    UtilityMenu.LaunchFinishMenu(user);
                    Alert.Confirmation();
                    break;

                case (int)Options.Exit:
                    start = false;
                    break;
                }
            } while (start);
        }
Example #2
0
        public static void LaunchProductMenu()
        {
            bool start = true;

            do
            {
                int option = (int)Options.Default;
                Banner.ShowBigBanner("Products");
                try
                {
                    option = int.Parse(Console.ReadLine());
                }
                catch (Exception)
                {
                    Alert.ShowAlert("Please type a valid Option", ConsoleColor.Red);
                    Alert.Confirmation();
                }
                switch (option)
                {
                case (int)Options.Create:
                    try
                    {
                        Banner.ShowBanner("Create Product");
                        ProductCtrl.CreateProduct(Product.GetAllInfo());
                        Alert.Confirmation();
                    }
                    catch (ApplicationException error)
                    {
                        Alert.ShowAlert(error.Message, ConsoleColor.Red);
                        Alert.Confirmation();
                        App.InitializeApp();
                    }
                    break;

                case (int)Options.Search:
                    try
                    {
                        Banner.ShowBanner("Search Product");
                        ProductCtrl.ReadProduct(Product.GetId().Id);
                        Alert.Confirmation();
                    }
                    catch (ApplicationException error)
                    {
                        Alert.ShowAlert(error.Message, ConsoleColor.Red);
                        Alert.Confirmation();
                        App.InitializeApp();
                    }
                    break;

                case (int)Options.Catalog:
                    try
                    {
                        Banner.ShowBanner("Product Database");
                        ProductCtrl.ReadAllProducts();
                        Alert.Confirmation();
                        break;
                    }
                    catch (ApplicationException error)
                    {
                        Alert.ShowAlert(error.Message, ConsoleColor.Red);
                        Alert.Confirmation();
                        App.InitializeApp();
                    }
                    break;

                case (int)Options.Update:
                    try
                    {
                        Banner.ShowBanner("Update Product");
                        ProductCtrl.UpdateProduct(Product.GetAllInfo());
                        Alert.Confirmation();
                    }
                    catch (ApplicationException error)
                    {
                        Alert.ShowAlert(error.Message, ConsoleColor.Red);
                        Alert.Confirmation();
                        App.InitializeApp();
                    }
                    break;

                case (int)Options.Delete:
                    try
                    {
                        Banner.ShowBanner("Delete Product");
                        ProductCtrl.DeleteProduct(Product.GetId().Id);
                        Alert.Confirmation();
                    }
                    catch (ApplicationException error)
                    {
                        Alert.ShowAlert(error.Message, ConsoleColor.Red);
                        Alert.Confirmation();
                        App.InitializeApp();
                    }
                    break;

                case (int)Options.Exit:
                    start = false;
                    break;
                }
            } while (start);
        }