Beispiel #1
0
        static void UserView()
        {
            User user  = new User();
            bool done  = false;
            var  input = 0;

            //create or use as existing user
            Console.WriteLine("Welcome to the user interfact, please select one of the following options: ");
            Console.WriteLine("1) Use app as an existing user");
            Console.WriteLine("2) Use app as a new user");
            while (!done)
            {
                int.TryParse(Console.ReadLine(), out input);

                if (input == 1)
                {
                    PrintAllUsers();
                    user = SelectUser();
                    done = true;
                }
                else if (input == 2)
                {
                    user = CreateNewUser();
                    done = true;
                }
                else
                {
                    Console.WriteLine("Please enter a valid option. (number 1 or 2)");
                }
            }
            // check if the user is properly defined
            if (user.Name == null)
            {
                Console.WriteLine("Name is not properly defined, check the associated methods");
            }
            // User Menu
            PrintAllStoresWithEF();
            System.Console.WriteLine("Please select a store");
            user.SelectedStore = SelectStore();

            Console.WriteLine("Selected Store is: ");
            Console.WriteLine(user.SelectedStore);

            //Make Pizza

            user.SelectedStore.CreateOrder(MakePizza(), user);

            user.Orders.Add(user.SelectedStore.Orders.Last());
            _sql.UpdateUser(user);
            _sql.UpdateStore(user.SelectedStore);
            UserMenu(user);
            System.Console.WriteLine("Thank you for choosing to use this app!");
        }