Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Select type of Pizza");
            Console.WriteLine("1. Cheese Pizza");
            Console.WriteLine("2. Pepperoni Pizza");
            Console.WriteLine("3. Clam Pizza");
            Console.WriteLine("4. Veggie Pizza");

            String type = Console.ReadLine().ToString();

            PizzaStore pizzaStore = new PizzaStore();

            pizzaStore.OrderPizza(type);

            Console.WriteLine("Your order is ready: " + pizzaStore.Name);
            Console.ReadLine();
        }
Пример #2
0
        public void ShouldCreateSpecificPizza(PizzaType pizzaType)
        {
            // Assign
            PizzaStore pizzaStore = null;

            switch (pizzaType)
            {
            case PizzaType.California:
                pizzaStore = new CaliforniaPizzaStore();
                break;

            case PizzaType.Chicago:
                pizzaStore = new ChicagoPizzaStore();
                break;

            case PizzaType.NewYork:
                pizzaStore = new NewYorkPizzaStore();
                break;
            }

            // Act
            IPizza pizza = pizzaStore.CreatePizza(new List <string>());

            this.output.WriteLine($"Pizza Store: {pizzaStore.GetType()}");
            this.output.WriteLine($"Pizza Type: {pizza.GetType()}");

            // Assert
            switch (pizzaType)
            {
            case PizzaType.California:
                Assert.NotNull(pizza as CaliforniaPizza);
                break;

            case PizzaType.Chicago:
                Assert.NotNull(pizza as ChicagoPizza);
                break;

            case PizzaType.NewYork:
                Assert.NotNull(pizza as NewYorkPizza);
                break;
            }
        }
Пример #3
0
        public void NewOrderShouldDecreaseStoreInventoryByPositiveAmount(int amount) //* inventory decreases when orders are accepted
        {
            //Arrange
            PizzaStore newPizzaStore      = new PizzaStore();
            Customer   newCustomer        = new Customer();
            Pizza      cheesePizza        = new Pizza();
            Dictionary <Pizza, int> order = new Dictionary <Pizza, int>()
            {
                { cheesePizza, amount }
            };
            var originalInventory = new Dictionary <string, int> (newPizzaStore.Inventory);

            //Act
            newPizzaStore.PlacedOrder(newCustomer, order);
            var decreasedInventory = new Dictionary <string, int>(newPizzaStore.Inventory);

            foreach (var item in cheesePizza.Items)
            {
                Assert.Equal(originalInventory[item.Key], decreasedInventory[item.Key] + (amount * item.Value));
            }
        }
Пример #4
0
        public void CustomerCannotPlaceMoreTwoOrdersFromSameLocationWithinTwoHours()
        {
            //Arrange
            PizzaStore newPizzaStore      = new PizzaStore();
            Customer   newCustomer        = new Customer();
            Pizza      cheesePizza        = new Pizza();
            Dictionary <Pizza, int> order = new Dictionary <Pizza, int>()
            {
                { cheesePizza, 1 }
            };
            Dictionary <Pizza, int> order2 = new Dictionary <Pizza, int>()
            {
                { cheesePizza, 1 }
            };

            //Act
            newPizzaStore.PlacedOrder(newCustomer, order);

            //Assert
            Assert.Throws <Exception>(() => newPizzaStore.PlacedOrder(newCustomer, order));
        }
Пример #5
0
 /// <summary>
 /// The main.
 /// </summary>
 public static void Main()
 {
     PizzaStore pizzaStore = new PizzaStore(new SimplePizzaFactory());
     Pizza      pizza      = pizzaStore.OrderPizza("cheese");
 }
Пример #6
0
 /// <summary>
 /// Update a pizza store restaurant.
 /// </summary>
 /// <param name="restaurant">The restaurant with changed values</param>
 /// <remarks>Have to make sure pizza store obj arg has all the same fields as original (except ones changing)</remarks>
 public void UpdateStore(PizzaStore restaurant)
 {
     locationRepo.UpdateT(Mapper.Map(restaurant));
 }
Пример #7
0
        /// <summary>
        /// Delete a pizza restaurant by ID.
        /// </summary>
        /// <param name="restaurantId">The ID of the restaurant</param>
        public void DeleteStore(PizzaStore rest)
        {
            Location store = Mapper.Map(rest);

            locationRepo.DeleteT(store);
        }
Пример #8
0
 private static void Main(string[] args)
 {
     var store = new PizzaStore(new SimplePizzaFactory());
     var pizza = store.OrderPizza("cheese");
 }
        // static List<User> UserDataBase = new List<User>(); //What would eventually be a user database
        // static List<Store> StoreDataBase = new List<Store>(); //What would eventually be a store database

        static void Main(string[] args)
        {
            //Console.WriteLine("Hello");



            var repo       = Dependencies.CreatePizzaUserRepository();
            var PizzaUsers = repo.GetPizzaUser();

            var repoStore   = Dependencies.CreatePizzaStoreRepository();
            var PizzaStores = repoStore.GetPizzaStore();

            var repoOrder   = Dependencies.CreatePizzaOrderRepository();
            var PizzaOrders = repoOrder.GetPizzaOrder();

            var repoPizza = Dependencies.CreatePizzaPizza();
            var Pizzas    = repoPizza.GetPizza();

            Console.WriteLine("Database Connected\n");

            /*
             * foreach (PizzaStore store in PizzaStores)
             * {
             *  Console.WriteLine(store.Storename + " " + store.PresetSpecial + " ! " + store.PresetPizzaId);
             * }
             */

            //Store Test

            /*
             * foreach (var st in PizzaStores)
             * {
             *  Console.WriteLine($"{st.Storename} {st.PresetSpecial} ");
             * }
             */


            //USER TEST

            /*
             * foreach (var pu in PizzaUsers)
             * {
             *  Console.WriteLine($"{pu.Username}: {pu.FirstName} {pu.LastName}");
             *
             * }
             */


Home:
            PizzaUsers  = repo.GetPizzaUser();
            PizzaStores = repoStore.GetPizzaStore();
            PizzaUser  currentPizzaUser  = null;
            PizzaStore currentPizzaStore = null;

            string storeChoice = null;


            Console.Clear();
            Console.WriteLine("-----------------------------------------------------------------------");
            Console.WriteLine("Welcome to the PizzaBox Client \n Your Pie Awaits!");
            System.Threading.Thread.Sleep(1000);
            Console.WriteLine("Are you a 'User' or a 'Store' ?\n");
            Console.WriteLine("-----------------------------------------------------------------------");

            string type = Console.ReadLine();


            // Authenticated Loggin or Sign Up
            switch (type)
            {
            case "Quit":
                goto Quit;

            case "Store":
StoreLogin:
                //Console.WriteLine("Hello Store");

                Console.WriteLine("Login or Sign Up");
                string res1Store = Console.ReadLine();
                switch (res1Store)
                {
                case "Login":
                    Console.Write("Storename: ");
                    string storename = Console.ReadLine();
                    Console.WriteLine();
                    System.Console.Write("Password: "******"Welcome back {st.Storename}");
                                currentPizzaStore = st;

                                goto StoreSignedIn;
                            }
                        }
                    }
                    catch (NullReferenceException)
                    {
                        Console.WriteLine("Nothing Found Here");
                    }
                    Console.WriteLine("Invalid Store Name or Password\n");
                    goto StoreLogin;


                case "Sign Up":
StoreSignUp:
                    Console.WriteLine("Welcome Please Fill Out Your Information \n");

                    Console.Write("Store Name: ");
                    string su1 = Console.ReadLine();
                    Console.WriteLine();
                    Console.Write("Password: "******"Cell: ");
                    string su3 = Console.ReadLine();
                    Console.WriteLine();
                    Console.Write("Store's Address: ");
                    string su4 = Console.ReadLine();
                    Console.WriteLine();

res2Store:
                    Console.WriteLine("Is This Information Correct? ");
                    Console.WriteLine("Store Name: " + su1);
                    Console.WriteLine("Password: "******"Store's Cell: " + su3);
                    Console.WriteLine("Store's Address: " + su4);
                    Console.WriteLine();
                    Console.WriteLine("Yes or No");

                    string resSignUpStore = Console.ReadLine();
                    switch (resSignUpStore)
                    {
                    case "Yes":

                        PizzaStore temp = new PizzaStore(su1, su2, su3, su4);
                        repoStore.AddPizzaStore(temp);

                        Console.WriteLine("Thank You for Registering Your Store on PizzaBox");
                        goto Home;

                    case "No":
                        goto StoreSignUp;


                    case "Home":
                        goto Home;

                    default:
                        Console.WriteLine();
                        Console.WriteLine("Invalid Input");
                        goto res2Store;
                    }


                case "Home":
                    goto Home;

                default:
                    Console.WriteLine("Invalid Responce\n");
                    goto StoreLogin;
                }



            case "User":
TypeUser:
                Console.WriteLine("'Login' or 'Sign Up'");
                string res1User = Console.ReadLine();
                switch (res1User)
                {
                case "Login":
                    Console.Write("Username: "******"Password: "******"Welcome back {pu.FirstName}");
                                currentPizzaUser = pu;

                                goto UserSignedIn;
                            }
                        }
                    }
                    catch (NullReferenceException)
                    {
                        Console.WriteLine("Nothing Found Here");
                    }
                    Console.WriteLine("No Matching User Name or Password");
                    goto TypeUser;


                case "Sign Up":
UserSignUp:
                    Console.WriteLine("Welcome Please Fill Out Your Information \n");

                    Console.Write("Username: "******"Password: "******"First Name: ");
                    string su3 = Console.ReadLine();
                    Console.WriteLine();
                    Console.Write("Last Name: ");
                    string su4 = Console.ReadLine();
                    Console.WriteLine();
                    Console.Write("Cell: ");
                    string su5 = Console.ReadLine();
                    Console.WriteLine();
                    Console.Write("Address: ");
                    string su6 = Console.ReadLine();
                    Console.WriteLine();
                    Console.Write("Email: ");
                    string su7 = Console.ReadLine();
                    Console.WriteLine();


                    Console.WriteLine("Is This Information Correct? ");
                    Console.WriteLine("Username: "******"Password: "******"First Name: " + su3);
                    Console.WriteLine("Last Name: " + su4);
                    Console.WriteLine("Cell: " + su5);
                    Console.WriteLine("Address: " + su6);
                    Console.WriteLine("Email " + su7);
                    Console.WriteLine("Yes or No");

res3:
                    string resSignUpUser = Console.ReadLine();
                    switch (resSignUpUser)
                    {
                    case "Yes":


                        PizzaUser temp = new PizzaUser(su1, su2, su3, su4, su5, su6, su7);

                        repo.AddPizzaUser(temp);
                        Console.WriteLine("Thanks For Signing Up!");
                        goto Home;


                    case "No":
                        goto UserSignUp;


                    case "Home":
                        goto Home;

                    default:
                        Console.WriteLine("Invalid Input: Please Enter 'Yes' to confirm account , 'No' to re-enter your information or enter 'Home' to return to the main menu\n");
                        goto res3;
                    }


                case "Home":
                    goto Home;

                default:
                    Console.WriteLine("Invalid Input");
                    goto TypeUser;        //Outer Default for Selecting User Type
                }



            default:     //Outer Default for Type
                Console.WriteLine("Invalid Input");
                goto Home;
            }


UserSignedIn:
            Console.Clear();
            Console.WriteLine("Welcome Back. Lets Get Some Pizza");

InvRes:
            Console.WriteLine("-----------------------------------------------------------------------");
            Console.WriteLine("Currently you can: \nView Pizza Locations : (View)\nSelect a Pizza Location: (Select) ");
            Console.WriteLine("Look at your Order History: (History)");
            Console.WriteLine("Selecting a location will allow you to create an order");
            Console.WriteLine("-----------------------------------------------------------------------");
            string ul1 = Console.ReadLine();


            if (ul1.Equals("View"))
            {
                Console.Clear();
                Console.WriteLine("-----------------------------------------------------------------------");
                Console.WriteLine("Here are list of spots to grab a pie!\n");

                PizzaStores = repoStore.GetPizzaStore();

                foreach (PizzaStore store in PizzaStores)
                {
                    //Console.Clear();
                    Console.WriteLine($"{store.Storename,0} {store.StoreAddress,-10} {store.Cell,-10}");
                    //Console.Clear();
                }
                Console.WriteLine("-----------------------------------------------------------------------");
                Console.WriteLine();
                goto InvRes;
            }
            if (ul1.Equals("History"))
            {
                Console.Clear();
                Console.WriteLine("Viewing Your Order History\n");
                Console.WriteLine("-----------------------------------------------------------------------");

                var history = repoOrder.GetPizzaOrderHistoryUser(currentPizzaUser.Username);
                foreach (var order in history)
                {
                    Console.WriteLine($"Order: {order.Orderid,0} Store: {order.Storename,-5} {(decimal)order.Cost,-5:C} {order.OrderDate,-5}");
                }
                Console.WriteLine("-----------------------------------------------------------------------");
                Console.WriteLine();
                goto InvRes;
            }

            if (ul1.Equals("Logout"))
            {
                Console.WriteLine("Logging Out\n");
                System.Threading.Thread.Sleep(3000);
                Console.Clear();

                goto Home;
            }
            if (ul1.Equals("Select"))
            {
                Console.Clear();
                Console.WriteLine("-----------------------------------------------------------------------");
                Console.WriteLine("What PizzaStore would you like to order from ? ");
                foreach (PizzaStore store in PizzaStores)
                {
                    Console.WriteLine($"{store.Storename,0} Address:{store.StoreAddress,-10} Cell: {store.Cell,-5}");
                }
                Console.WriteLine("-----------------------------------------------------------------------");
                Console.WriteLine();
                string location   = Console.ReadLine();
                bool   storeExist = false;
                foreach (PizzaStore store in PizzaStores)
                {
                    if (store.Storename.Equals(location))
                    {
                        storeExist = true;
                    }
                }

                switch (storeExist)
                {
                case true:
                    storeChoice = location;
                    goto UserStorePage;

                case false:
                    Console.WriteLine("Location Does Not Exist");
                    goto InvRes;
                }
            }//Select
            else
            {
                Console.WriteLine("Invalid Input\n");
                goto InvRes;
            }


UserStorePage:
startOrder:
            Console.Clear();
            Console.WriteLine("-----------------------------------------------------------------------");
            Console.WriteLine("Your store choice =  " + storeChoice);
            Console.WriteLine("Would you like to start an order");
            Console.WriteLine("-----------------------------------------------------------------------");
            //Console.WriteLine(storeChoice);
            //Console.WriteLine("Note: Starting and order adds you to Store's Account");
            Console.WriteLine("'Yes' or 'No' ");
            string resStartOrder = Console.ReadLine();

            if (resStartOrder.Equals("Yes"))
            {
                PizzaOrder TempOrder = new PizzaOrder();
                TempOrder.Username  = currentPizzaUser.Username;
                TempOrder.Storename = storeChoice;
                int storeSpecialID;

                Console.WriteLine("Lets take a look at the menus");
                foreach (var pizzastore in PizzaStores)
                {
                    if (pizzastore.Storename.Equals(storeChoice))
                    {
                        storeSpecialID = (int)pizzastore.PresetPizzaId;



                        string specialpizza = (pizzastore.PresetSpecial);



                        if (specialpizza.Length > 1)
                        {
wantSpecial:
                            Console.Clear();
                            Console.WriteLine("-----------------------------------------------------------------------");
                            Console.WriteLine($"The house special pizza is {specialpizza}");
                            Console.WriteLine("Would you like to add this to your order? Yes or No");
                            Console.WriteLine("-----------------------------------------------------------------------");
                            string resPresetPizza = Console.ReadLine();
                            switch (resPresetPizza)
                            {
                            case "No":
                                break;


                            case "Yes":
                                //get pizza by id and get cost and ad to order

                                TempOrder.PizzaOne = storeSpecialID;
                                repoPizza          = Dependencies.CreatePizzaPizza();
                                TempOrder.Cost    += repoPizza.GetPizzaPrice(storeSpecialID);


inResCont:
                                Console.Clear();
                                Console.WriteLine("-----------------------------------------------------------------------");
                                Console.WriteLine($"Your Current Total Is: {TempOrder.Cost:C}");
                                Console.WriteLine("Would you like to continue order with a custom Pizza? Yes or No");
                                Console.WriteLine("-----------------------------------------------------------------------");
                                string resContinue = Console.ReadLine();
                                switch (resContinue)
                                {
                                case "Yes":
                                    Pizza tempPizza = new Pizza();
createCustom:
                                    //Create Custom Pizza and Add it

                                    Console.Clear();
                                    Console.WriteLine("What kind of crust would you like:");
                                    String[] crusts = { "Regular", "Thin", "Deep Dish", "Stuffed" };
                                    String[] sizes  = { "Small", "Medium", "Large", "X-Large" };

                                    foreach (String crust in crusts)
                                    {
                                        Console.WriteLine(crust);
                                    }
                                    string crustChoice = Console.ReadLine();
                                    switch (crustChoice)
                                    {
                                    case "Regular":
                                    case "Thin":
                                    case "Deep Dish":
                                    case "Stuffed":
                                        tempPizza.Crust = crustChoice;
                                        break;

                                    default:
                                        Console.WriteLine("Invalid Input");
                                        System.Threading.Thread.Sleep(2000);
                                        goto createCustom;
                                    }
pickSize:
                                    Console.Clear();
                                    Console.WriteLine("-----------------------------------------------------------------------");
                                    Console.WriteLine("What size pizza would you like?");
                                    Console.WriteLine("-----------------------------------------------------------------------");
                                    foreach (String size in sizes)
                                    {
                                        Console.WriteLine(size);
                                    }
                                    Console.WriteLine("-----------------------------------------------------------------------");
                                    string sizeChoice = Console.ReadLine();
                                    switch (sizeChoice)
                                    {
                                    case "Small":
                                    case "Medium":
                                    case "Large":
                                    case "X-Large":
                                        tempPizza.Size = sizeChoice;
                                        break;

                                    default:
                                        Console.WriteLine("Invalid Input");
                                        System.Threading.Thread.Sleep(2000);
                                        goto pickSize;
                                    }

                                    Console.Clear();
Toppings:
                                    Console.WriteLine("Add up to three toppings");
                                    Console.WriteLine("-----------------------------------------------------------------------");
                                    bool x        = true;
                                    int  toppings = 0;
                                    tempPizza.Pepper      = 0;
                                    tempPizza.ExtraCheese = 0;
                                    tempPizza.Bacon       = 0;
                                    tempPizza.Mozzerella  = 0;
                                    tempPizza.Pepperoni   = 0;
                                    tempPizza.Sausage     = 0;
                                    tempPizza.Pineapple   = 0;
                                    tempPizza.Onion       = 0;
                                    tempPizza.Chicken     = 0;
                                    while (x)
                                    {
                                        Console.WriteLine("Extra Cheese? Yes or No");
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        string cheese = Console.ReadLine();
                                        if (cheese.Equals("Yes"))
                                        {
                                            tempPizza.ExtraCheese = 1;
                                            toppings++;
                                        }
                                        else if (cheese.Equals("No"))
                                        {
                                            tempPizza.ExtraCheese = 0;
                                        }
                                        else
                                        {
                                            goto Toppings;
                                        }

                                        Console.WriteLine("Bacon? Yes or No");
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        string bacon = Console.ReadLine();
                                        if (bacon.Equals("Yes"))
                                        {
                                            tempPizza.Bacon = 1;
                                            toppings++;
                                        }
                                        else if (bacon.Equals("No"))
                                        {
                                            tempPizza.Bacon = 0;
                                        }
                                        else
                                        {
                                            goto Toppings;
                                        }
                                        Console.WriteLine("Pepperoni? Yes or No");
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        string pepe = Console.ReadLine();
                                        if (pepe.Equals("Yes"))
                                        {
                                            tempPizza.Pepperoni = 1;
                                            toppings++;
                                        }
                                        else if (pepe.Equals("No"))
                                        {
                                            tempPizza.Pepperoni = 0;
                                        }
                                        else
                                        {
                                            goto Toppings;
                                        }
                                        Console.WriteLine("Mozzerella? Yes or No");
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        string moz = Console.ReadLine();
                                        if (moz.Equals("Yes"))
                                        {
                                            tempPizza.Mozzerella = 1;
                                            toppings++;
                                        }
                                        else if (moz.Equals("No"))
                                        {
                                            tempPizza.Mozzerella = 0;
                                        }
                                        else
                                        {
                                            goto Toppings;
                                        }
                                        Console.WriteLine("Sausage? Yes or No");
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        string sau = Console.ReadLine();
                                        if (sau.Equals("Yes"))
                                        {
                                            tempPizza.Sausage = 1;
                                            toppings++;
                                        }
                                        else if (sau.Equals("No"))

                                        {
                                            tempPizza.Sausage = 0;
                                        }
                                        else
                                        {
                                            goto Toppings;
                                        }
                                        Console.WriteLine("Pineapple? Yes or No");
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        string pine = Console.ReadLine();

                                        if (pine.Equals("Yes"))
                                        {
                                            tempPizza.Pineapple = 1;
                                            toppings++;
                                        }
                                        else if (pine.Equals("No"))
                                        {
                                            tempPizza.Pineapple = 0;
                                        }
                                        else
                                        {
                                            goto Toppings;
                                        }
                                        Console.WriteLine("Onions? Yes or No");
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        string oni = Console.ReadLine();
                                        if (oni.Equals("Yes"))
                                        {
                                            tempPizza.Onion = 1;
                                            toppings++;
                                        }
                                        else if (oni.Equals("No"))
                                        {
                                            tempPizza.Onion = 0;
                                        }
                                        else
                                        {
                                            goto Toppings;
                                        }
                                        Console.WriteLine("Chicken? Yes or No");
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        string chi = Console.ReadLine();
                                        if (chi.Equals("Yes"))
                                        {
                                            tempPizza.Chicken = 1;
                                            toppings++;
                                        }
                                        else if (chi.Equals("No"))
                                        {
                                            tempPizza.Chicken = 0;
                                        }
                                        else
                                        {
                                            goto Toppings;
                                        }
                                        Console.WriteLine("Peppers? Yes or No");
                                        string pep = Console.ReadLine();
                                        if (cheese.Equals("Yes"))
                                        {
                                            tempPizza.Pepper = 1;
                                            toppings++;
                                        }
                                        else if (pep.Equals("No"))
                                        {
                                            tempPizza.Pepper = 0;
                                        }
                                        else
                                        {
                                            goto Toppings;
                                        }



                                        if (toppings > 3)
                                        {
                                            Console.WriteLine("TOO MANY TOPPINGS ! CHOOSE TOPPINGS AGAIN");
                                            Console.WriteLine("-----------------------------------------------------------------------");
                                            System.Threading.Thread.Sleep(2000);
                                            goto Toppings;
                                        }
                                        if (toppings < 4)
                                        {
                                            x = false;
                                        }
                                    }        //while

                                    tempPizza.Cost  = (decimal)tempPizza.ComputePrice(toppings);
                                    TempOrder.Cost += tempPizza.Cost;

                                    repoPizza = Dependencies.CreatePizzaPizza();
                                    repoPizza.AddPizza(tempPizza);
                                    Pizzas = repoPizza.GetPizza();

                                    int newID = repoPizza.GetLastPizza();
                                    TempOrder.PizzaTwo = Convert.ToInt32(newID);
                                    Console.Clear();
SubmitO:
                                    Console.WriteLine("-----------------------------------------------------------------------");
                                    Console.WriteLine($"So your total is {TempOrder.Cost:C}");
                                    Console.WriteLine("Would you like to confirm and place your order? Yes or No?");
                                    Console.WriteLine("-----------------------------------------------------------------------");
                                    string placeOrder = Console.ReadLine();

                                    switch (placeOrder)
                                    {
                                    case "Yes":
                                        Console.Clear();
                                        repoOrder.AddPizzaOrder(TempOrder);
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Write(".");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Write(".");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Write(".");
                                        Console.WriteLine("Done");
                                        Console.WriteLine("Your Pizza Should Arrive in 30 Minutes or Less");
                                        System.Threading.Thread.Sleep(3000);
                                        goto UserSignedIn;


                                    case "No":
                                        Console.WriteLine("The Pizza Didnt Want You Either!");
                                        Console.WriteLine("Discarding Order");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Write(".");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Write(".");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Write(".");
                                        Console.WriteLine("Done");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Clear();
                                        goto UserSignedIn;

                                    default:
                                        Console.WriteLine("Invalid Input");
                                        System.Threading.Thread.Sleep(3000);
                                        goto SubmitO;
                                    }



                                case "No":
NoMore:
                                    Console.Clear();
                                    Console.WriteLine("-----------------------------------------------------------------------");
                                    Console.WriteLine("Confirm Order? Yes or No");
                                    Console.WriteLine("'No' will discard your order");
                                    Console.WriteLine("-----------------------------------------------------------------------");
                                    string endOrder = Console.ReadLine();
                                    switch (endOrder)
                                    {
                                    case "Yes":


                                        repoOrder.AddPizzaOrder(TempOrder);
                                        //TODO in API update so order does not get posted if it is alread there
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        Console.WriteLine("Your pizza is being crafted as we speak");
                                        Console.WriteLine("The pizza will be delievered in 30 mins or less");
                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        System.Threading.Thread.Sleep(3000);

                                        goto UserSignedIn;


                                    case "No":

                                        Console.WriteLine("-----------------------------------------------------------------------");
                                        Console.WriteLine("The Pizza Didnt Want You Either!");
                                        Console.WriteLine("Discarding Order");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Write(".");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Write(".");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Write(".");
                                        Console.WriteLine("Done");
                                        Console.WriteLine("Taking You back to the User Homepage");
                                        System.Threading.Thread.Sleep(3000);
                                        Console.Clear();

                                        goto UserSignedIn;

                                    default:
                                        Console.WriteLine("Invalid Response\n");
                                        System.Threading.Thread.Sleep(3000);
                                        goto NoMore;
                                    }



                                default:
                                    Console.WriteLine("Invalid Responce\n");
                                    System.Threading.Thread.Sleep(3000);
                                    goto inResCont;
                                }



                            default:
                                Console.WriteLine("Invalid Response\n");

                                goto wantSpecial;
                            }
                        }
                        else
                        {
resStartOrder1:
                            Console.WriteLine("-----------------------------------------------------------------------");
                            Console.WriteLine("This store has no special! Lets customize a pizza for you!");
                            goto strrtCustom;// Make Custom
                        }
                    }
                }
strrtCustom:
                Console.WriteLine();
                Console.Clear();
            }
            if (resStartOrder.Equals("No"))
            {
                goto UserSignedIn;
            }
            else
            {
                Console.WriteLine("Invalid Response");
                goto startOrder;
            }//NOT Starting Order



StoreSignedIn:
            Console.Clear();
ValidStoreInput:
            Console.WriteLine();
            Console.WriteLine("-----------------------------------------------------------------------");
            Console.WriteLine("Welcome Back. Lets Sell Some Pizzas\n");
            Console.WriteLine("Currently you can: \nView Compleyed Orders: (Orders)\nView Sales: (Sales) ");
            Console.WriteLine("Look at your customers: (Users)");
            Console.WriteLine("-----------------------------------------------------------------------");
            repoOrder = Dependencies.CreatePizzaOrderRepository();
            var pizzaOrdersForStore = repoOrder.GetOrders(currentPizzaStore.Storename);

            string sl1 = Console.ReadLine();

            switch (sl1)
            {
            case ("Orders"):
                Console.WriteLine("Lets view those completed orders");

                Console.WriteLine("-----------------------------------------------------------------------");
                Console.WriteLine("");
                foreach (PizzaOrder o in pizzaOrdersForStore)
                {
                    Console.WriteLine($"{o.Username,0} {o.Cost,-10:C} {o.OrderDate,-10}");
                }
                goto ValidStoreInput;


            case ("Sales"):
                Console.WriteLine("-----------------------------------------------------------------------");
                Console.WriteLine("Lets look at the income");
                //Query Method
                int     count      = 0;
                decimal totalSales = 0.0m;
                foreach (PizzaOrder o in pizzaOrdersForStore)
                {
                    count++;
                    totalSales = totalSales + (decimal)o.Cost;
                }
                Console.WriteLine("Total Number of Sales: " + count);
                Console.WriteLine($"Total Revenue: {totalSales:C}");
                Console.WriteLine("-----------------------------------------------------------------------");
                goto ValidStoreInput;

            case ("Users"):
                Console.WriteLine("-----------------------------------------------------------------------");
                Console.WriteLine("Lets look at all the users registered with your store");
                Console.WriteLine("-----------------------------------------------------------------------");

                pizzaOrdersForStore = repoOrder.GetOrders(currentPizzaStore.Storename);
                var RepoUser      = Dependencies.CreatePizzaUserRepository();
                var namesForStore = RepoUser.GetPizzaUser();

                foreach (PizzaOrder o in pizzaOrdersForStore)
                {
                    Console.WriteLine($"{o.Username,-10} ");
                }

                goto ValidStoreInput;

            case ("Logout"):
                Console.WriteLine("Signing Off...");

                goto Home;



            default:
                Console.WriteLine("Invalid Input");
                System.Threading.Thread.Sleep(3000);
                Console.Clear();
                goto StoreSignedIn;
            }



Quit:
            Console.Clear();
            Console.WriteLine("-----------------------------------------------------------------------");
            Console.WriteLine("Thank You For Using PizzaBox\n Have a pie day! ");
        } //Main
Пример #10
0
        private static void runFactory()
        {
            var pizzaStore = new PizzaStore(new PizzaFactory(new SyracuseIngredientFactory()));

            var pizza = pizzaStore.OrderPizza(PizzaStyle.Pepperoni);
        }
 public PizzaStoreShould()
 {
     _sut = new PizzaStore();
 }
Пример #12
0
        public Form1()
        {
            _store = PizzaStore.GetInstance(new SimplePizzaFactory());

            InitializeComponent();
        }
Пример #13
0
 /// <summary>
 /// Update a pizza store restaurant.
 /// </summary>
 /// <param name="restaurant">The restaurant with changed values</param>
 /// <remarks>Have to make sure pizza store obj arg has all the same fields as original (except ones changing)</remarks>
 public void UpdateStore(PizzaStore restaurant)
 {
     DeleteStore(restaurant.Id);
     AddStore(restaurant);
 }
Пример #14
0
        public static void Main(string[] args)
        {
            Console.WriteLine("\n\n\r===========Working with Strategy Pattern=======");

            RedHeadDuck redHeadDuck = new RedHeadDuck();

            redHeadDuck.PerformFly();
            redHeadDuck.PerformQuack();
            redHeadDuck.Swim();
            redHeadDuck.Display();
            Console.WriteLine("\n\rSetting the Behaviour for Ducks that exibit different Behaviours");

            RubberDuck rubberDuck = new RubberDuck();

            rubberDuck.PerformFly();
            rubberDuck.SetFlyBehaviour(new FlyWithRockets());
            rubberDuck.PerformFly();
            rubberDuck.PerformQuack();


            Console.WriteLine("\n\n\r===========Working with Observer Pattern=======");

            WeatherData WeatherData = new WeatherData();

            ForecastDisplay forcastDisplay = new ForecastDisplay(WeatherData);

            WeatherData.WeatherMeasurements(15, 20, 25);

            Console.WriteLine("\n\n\r===========Working with Classic Singleton=======");
            ClassicSingleton classicSingleton = ClassicSingleton.GetInstance();

            classicSingleton.Description();

            Console.WriteLine("\n\n\r===========Working with Static Singleton=======");
            StaticSingleton staticSingleton = StaticSingleton.GetInstance();

            staticSingleton.Description();

            Console.WriteLine("\n\n\r===========Working with Singleton using syncronization=======");
            SingletonUsingSyncronization syncronizedSingleton = SingletonUsingSyncronization.GetInstance();

            syncronizedSingleton.Description();


            Console.WriteLine("\n\n\r===========Working with Factory Design Pattern=======");
            SimplePizzaFactory factory = new SimplePizzaFactory();

            PizzaStore store = new PizzaStore(factory);
            Pizza      pizza = store.OrderPizza("Cheese");

            Console.WriteLine(pizza.ToString());

            Console.WriteLine("\nState Machine Design Pattern");

            GumballMachine machine = new GumballMachine(5);

            Console.WriteLine(machine);

            machine.InsertQuarter();
            machine.EjectQuarter();
            machine.TurnCrank();
            Console.WriteLine(machine);

            Console.WriteLine("\n Working with Iterators");
            DinnerMenu dinnerMenu = new DinnerMenu();

            DesignPatterns.Iterator.Iterator iterator = dinnerMenu.CreateIterator();

            while (iterator.HasNext())
            {
                var current = iterator.Next();
                Console.WriteLine(current);
            }

            Console.WriteLine("\n============================");
            PanCakeHouseMenu panMenu = new PanCakeHouseMenu();

            DesignPatterns.Iterator.Iterator panIterator = panMenu.CreateIterator();

            while (panIterator.HasNext())
            {
                var current = panIterator.Next();
                Console.WriteLine(current);
            }
        }
Пример #15
0
        static void Main(string[] args)
        {
            var               saveLocation = "../../../../json.txt";
            string            input;
            List <PizzaStore> stores;
            List <Orders>     orders;
            List <Library.Models.Customer> customers;
            //List<Inventory> storeInventory;
            var dataSource = new List <PizzaStore>();  //for initializing repo

            var optionsBuilder = new DbContextOptionsBuilder <project0Context>();

            optionsBuilder.UseSqlServer(secretConfiguration.ConnectionString); //pass options builder what sql server to use and login info
            var options   = optionsBuilder.Options;
            var dbContext = new project0Context(options);

            var storeRepository    = new PizzaStoreRepository(dbContext);
            var orderRepository    = new OrderRepo(dbContext);
            var customerRepository = new CustomerRepo(dbContext);

            //var inventoryRepository = new InventoryRepo(dbContext);

            //testing serialization worked with multiple stores
            //storeRepository.AddStore(new PizzaStore());
            //storeRepository.AddStore(new PizzaStore());

            while (true) //loop until exit command given
            {
                Console.WriteLine("p:\tDisplay or modify pizza stores.");
                Console.WriteLine("a:\tTo add pizza store.");
                Console.WriteLine("c:\tDisplay or add customers.");
                //Console.WriteLine("o:\tTo place order");
                Console.WriteLine("s:\tSave data to disk.");
                //Console.WriteLine("l:\tLoad data from disk.");
                Console.Write("Enter valid menu option, or \"exit\" to quit: ");
                input = Console.ReadLine(); //read command from console

                if (input == "p")           //still need other use cases
                {
                    while (true)
                    {
                        DisplayOrModifyStores();
                        input = Console.ReadLine();

                        if (input == "b")
                        {
                            break;
                        }
                        else if (int.TryParse(input, out var storeNum) &&
                                 storeNum > 0 && storeNum <= stores.Count)   //if input is a valid store number
                        {
                            while (true)
                            {
                                //display chosen stores info
                                var store       = stores[storeNum - 1];
                                var storeString = $"ID: {store.Id}, Name: \"{store.Name}\"";
                                //storeString += ", at Location: " + store.Location.ToString();

                                Console.WriteLine(storeString);
                                Console.WriteLine();

                                Console.WriteLine("o:\tDisplay orders.");
                                Console.WriteLine("i:\tDisplay or modify inventory");
                                Console.Write("Enter valid menu option, or b to go back: ");

                                input = Console.ReadLine();
                                if (input == "b")
                                {
                                    break;
                                }
                                else if (input == "o")
                                {
                                    DisplayOrdersOfStore(store.Id);
                                }
                                else if (input == "i")
                                {
                                    if (store.Inventory == null)
                                    {
                                        Console.WriteLine("No inventory.");
                                    }
                                    else
                                    {
                                        Console.WriteLine("Inventory: ");
                                        foreach (var item in store.Inventory)
                                        {
                                            Console.WriteLine($"Item Name: \"{item.Key}\", " +
                                                              $"Item Quantity: \"{item.Value}\"");
                                        }
                                    }

                                    while (true)
                                    {
                                        Console.WriteLine("a:\tAdd inventory item.");
                                        Console.Write("Enter valid menu option, or b to go back: ");
                                        input = Console.ReadLine();

                                        if (input == "a")
                                        {
                                            Dictionary <string, int> inv = store.Inventory;
                                            AddInventoryItem(ref inv);
                                            store.Inventory = inv;
                                            storeRepository.UpdateStore(store);
                                        }
                                        else if (input == "b")
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine();
                            Console.WriteLine($"Invalid input \"{input}\".");
                            Console.WriteLine();
                        }
                    }
                }
                else if (input == "a")
                {
                    AddNewPizzaStore();
                }
                else if (input == "c")
                {
                    while (true)
                    {
                        DisplayAddOrModifyCustomers();

                        input = Console.ReadLine();
                        if (input == "b")
                        {
                            break;
                        }
                        else if (input == "a")
                        {
                            AddNewCustomer();
                        }
                        else if (int.TryParse(input, out var custNum) &&
                                 custNum > 0 && custNum <= customers.Count)   //if input is a valid store number
                        {
                            while (true)
                            {
                                //display chosen stores info
                                var cust       = customers[custNum - 1];
                                var custString = $"ID: {cust.Id}, Name: \"{cust.FirstName} {cust.LastName}\"";

                                Console.WriteLine(custString);

                                Console.WriteLine("c:\tModify customer");
                                Console.Write("Enter valid menu option, or b to go back: ");

                                input = Console.ReadLine();
                                if (input == "b")
                                {
                                    break;
                                }
                                else if (input == "c")
                                {
                                    ////Modify Customer!!!!!!!
                                }
                            }
                        }
                    }
                }
                //else if (input == "o")
                //{

                //}
                else if (input == "s")  //use serializer to save data to file
                {
                    SaveToFile();
                }
                //else if (input == "l") //loading data from file
                //{
                //    LoadFromFile();
                //}
                else if (input == "exit") //exits loop and therefore program
                {
                    break;
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine($"Invalid input \"{input}\".");
                    Console.WriteLine();
                }
            }



            void DisplayAddOrModifyCustomers()
            {
                customers = customerRepository.GetAllCustomer().ToList();
                Console.WriteLine();
                if (customers.Count == 0)
                {
                    Console.WriteLine("No customers.");
                }
                else
                {
                    for (var i = 1; i <= customers.Count; i++)
                    {
                        var customer   = customers[i - 1]; //indexing starts at 0
                        var custString = $"{i}: \"{customer.FirstName} {customer.LastName}\" ";
                        //storeString += $", at Location: {store.Location.ToString()}";

                        Console.WriteLine(custString);
                    }
                }

                Console.WriteLine("a:\tAdd customer.");
                Console.WriteLine();
                Console.WriteLine("Enter valid menu option, or \"b\" to go back: ");
            }

            void DisplayOrModifyStores()
            {
                stores = storeRepository.GetStores().ToList();
                Console.WriteLine();
                if (stores.Count == 0)
                {
                    Console.WriteLine("No pizza stores.");
                }

                for (var i = 1; i <= stores.Count; i++)
                {
                    var store       = stores[i - 1]; //indexing starts at 0
                    var storeString = $"{i}: \"{store.Name}\"";
                    //storeString += $", at Location: {store.Location.ToString()}";

                    Console.WriteLine(storeString);
                }

                Console.WriteLine();
                Console.WriteLine("Enter valid menu option, or \"b\" to go back: ");
            }

            void DisplayOrdersOfStore(int id)
            {
                orders = orderRepository.GetOrdersOfLocation(id).ToList();
                Console.WriteLine();
                if (orders.Count == 0)
                {
                    Console.WriteLine("No orders.");
                }

                for (var i = 1; i <= orders.Count; i++)
                {
                    var order     = orders[i - 1]; //indexing starts at 0
                    var ordString = $"{i}: Store\\: \"{order.StoreId}\", Customer\\: " +
                                    $"\"{order.CustomerId}\", Time\\: \"{order.OrderTime}";

                    Console.WriteLine(ordString);
                }
            }

            PizzaStore AddNewPizzaStore()
            {
                Console.WriteLine();

                string name = null;
                //Library.Models.Address address = null;
                Dictionary <string, int> inventory = null;

                while (true)
                {
                    Console.Write("Would you like to use the default name? (y/n)");
                    input = Console.ReadLine();
                    if (input == "y")
                    {
                        break;
                    }
                    else if (input == "n")
                    {
                        Console.Write("Enter the new pizza restaurant's name: ");
                        name = Console.ReadLine();
                        break;
                    }
                }

                //while (true)
                //{
                //    Console.Write("Would you like to use a default location? (y/n)");
                //    input = Console.ReadLine();

                //    if (input == "y")
                //    {
                //        break;
                //    }
                //    else if (input == "n")
                //    {
                //        address = NewAddress();
                //        break;
                //    }
                //}

                while (true)
                {
                    Console.Write("Would you like to use the default inventory? (y/n)");
                    input = Console.ReadLine();

                    if (input == "y")
                    {
                        break;
                    }
                    else if (input == "n")
                    {
                        inventory = NewInventory();
                        break;
                    }
                }

                //PizzaStore restaurant = new PizzaStore(name, inventory, address);
                PizzaStore restaurant = new PizzaStore(name, inventory);

                storeRepository.AddStore(restaurant);
                return(restaurant);
            }

            void AddNewCustomer()
            {
                Console.WriteLine();

                Console.Write("Enter the new customer's firstname: ");
                string firstname = Console.ReadLine();

                Console.Write("Enter the new customer's lastname: ");
                string lastname = Console.ReadLine();

                PizzaStore store;

                while (true)
                {
                    Console.Write("Would you like to use the default store? (y/n)");
                    input = Console.ReadLine();

                    if (input == "y")
                    {
                        store = new PizzaStore();
                        break;
                    }
                    else if (input == "n")
                    {
                        while (true)
                        {
                            Console.Write("Would you like to use a new store? (y/n)");
                            input = Console.ReadLine();
                            if (input == "y")
                            {
                                store = AddNewPizzaStore();
                                break;
                            }
                            else if (input == "n")
                            {
                                Console.Write("Enter existing store id: ");
                                input = Console.ReadLine();

                                store = storeRepository.GetStoreById(Convert.ToInt32(input));
                                break;
                            }
                        }

                        break;
                    }
                }

                Library.Models.Customer cust = new Library.Models.Customer(firstname, lastname, store);

                customerRepository.AddCustomer(cust);
            }

            void AddInventoryItem(ref Dictionary <string, int> inv)
            {
                Console.WriteLine("Enter the new item's name: ");
                string name = Console.ReadLine();

                Console.WriteLine("Enter the new item's amount: ");
                int amount = Convert.ToInt32(Console.ReadLine());

                inv.Add(name, amount);
                Console.WriteLine("Added");
            }

            Dictionary <string, int> NewInventory()
            {
                Dictionary <string, int> inventory = new Dictionary <string, int>();

                while (true)
                {
                    Console.Write("Would you like to add an inventory item? (y/n)");
                    input = Console.ReadLine();

                    if (input == "y")
                    {
                        try
                        {
                            AddInventoryItem(ref inventory);
                        }
                        catch (ArgumentException e)
                        {
                            //log it

                            Console.WriteLine(e.Message);
                            return(inventory);
                        }
                    }
                    else if (input == "n")
                    {
                        break;
                    }
                }

                return(inventory);
            }

            //Library.Models.Address NewAddress()
            //{
            //    string street, city, state, zipcode, country;
            //    Console.Write("Enter the new pizza restaurant's location - street: ");
            //    street = Console.ReadLine();
            //    Console.Write("Enter the new pizza restaurant's location - city: ");
            //    city = Console.ReadLine();
            //    Console.Write("Enter the new pizza restaurant's location - state: ");
            //    state = Console.ReadLine();
            //    Console.Write("Enter the new pizza restaurant's location - zipcode: ");
            //    zipcode = Console.ReadLine();
            //    Console.Write("Enter the new pizza restaurant's location - country: ");
            //    country = Console.ReadLine();
            //    try
            //    {
            //        return new Library.Models.Address(street, city, state, zipcode, country);
            //    }
            //    catch (ArgumentException ex)
            //    {
            //        Console.WriteLine(ex.Message);
            //    }
            //    return null;
            //}

            void SaveToFile()
            {
                Console.WriteLine();

                stores = storeRepository.GetStores().ToList(); //get list of all pizza stores

                try
                {
                    var serialized = JsonConvert.SerializeObject(stores, Formatting.Indented); //serialize to the file
                    File.WriteAllTextAsync(saveLocation, serialized);
                    Console.WriteLine("Saving Success.");
                }
                catch (SecurityException ex)
                {
                    Console.WriteLine($"Error while saving: {ex.Message}");
                }
                catch (IOException ex)
                {
                    Console.WriteLine($"Error while saving: {ex.Message}");
                }
                //other exceptions
            }

            //void LoadFromFile()
            //{
            //    Console.WriteLine();
            //    try
            //    {
            //        var deserialized = new List<PizzaStore>();
            //        deserialized = JsonConvert.DeserializeObject<List<PizzaStore>>(File.ReadAllText(saveLocation));
            //        if (deserialized != null)
            //        {
            //            deserialized.ToList();
            //        }

            //        Console.WriteLine("Loading Success.");
            //        var allStores = storeRepository.GetAllStores().ToList();

            //        foreach (var item in allStores) //delete current repo one restaraunt at a time
            //        {
            //            //try
            //            //{
            //                storeRepository.DeleteStore(item); //throws error!
            //            //}
            //            //catch (ArgumentOutOfRangeException e)
            //            //{
            //            //    Console.WriteLine(e.Message);
            //            //}
            //        }

            //        if (deserialized != null)
            //        {
            //            foreach (var item in deserialized) //replace with repo data from file
            //            {
            //                storeRepository.AddStore(item);
            //            }
            //        }
            //    }
            //    catch (FileNotFoundException) //if no save file
            //    {
            //        Console.WriteLine("No saved data found.");
            //    }
            //    catch (SecurityException ex)
            //    {
            //        Console.WriteLine($"Error while loading: {ex.Message}");
            //    }
            //    catch (IOException ex)
            //    {
            //        Console.WriteLine($"Error while loading: {ex.Message}");
            //    }
            //    //other exceptions?
            //}
        }