コード例 #1
0
        private static void DisplayHistoryFromLocation(List <List <Order> > masterList)
        {
            Console.WriteLine("\nPlease enter a location to return all orders made.");
            string location = Console.ReadLine();

            MasterOrderList.AllOrdersInLocation(masterList, location);
            Console.WriteLine("\nPress any key to continue..");
            Console.ReadLine();
            UIPrompt();
        }
コード例 #2
0
        // public static void UpdateOrder(int id, string productName, int quantity, string deliverBy)
        // {
        //   Order thisOrder = GetOrder(id);
        //   thisOrder.ProductName = productName;
        //   thisOrder.Quantity = quantity;
        //   thisOrder.DeliverBy = deliverBy;
        // }

        public static void DeleteOrder(int id)
        {
            for (int i = 0; i < MasterOrderList.Count; i++)
            {
                if (id == MasterOrderList[i].Id)
                {
                    MasterOrderList.RemoveAt(i);
                }
            }
        }
コード例 #3
0
        private static void DisplayHistoryFromUser(List <List <Order> > masterList)
        {
            Console.WriteLine("\nPlease enter a username and lastname to return all orders made.");
            string response = Console.ReadLine();

            string[] username = response.Split();
            MasterOrderList.AllOrdersInUser(masterList, username);
            Console.WriteLine("\nPress any key to continue..");
            Console.ReadLine();
            UIPrompt();
        }
コード例 #4
0
        public Order(string productName, int quantity, string deliverBy, int venderId, string venderName)
        {
            ProductName = productName;
            Quantity    = quantity;
            DeliverBy   = deliverBy;
            VenderId    = venderId;
            VenderName  = venderName;
            Id          = IdCounter++;

            MasterOrderList.Add(this);
        }
コード例 #5
0
        private static void SearchUser(List <List <Order> > masterList)
        {
            Console.WriteLine("\nPlease enter a username to search.");
            string username = Console.ReadLine();

            string[] answer = username.Split();
            MasterOrderList.SearchUser(masterList, answer);
            Console.WriteLine("\nPress any key to continue..");
            Console.ReadLine();
            UIPrompt();
        }
コード例 #6
0
        private static void UIPromptChoice(string choice)
        {
            switch (choice)
            {
            case "1":
                SearchUser(masterList);
                break;

            case "2":
                DisplayHistoryFromLocation(masterList);
                break;

            case "3":
                DisplayHistoryFromUser(masterList);
                break;

            case "4":
                //SuggestedOrder(currentlist);
                break;

            case "5":
                if (MasterOrderList.NumberOfOrdersValid(currentListOfUserOrders.Count))
                {
                    masterList.Add(UsersListOfOrders());

                    foreach (var order in currentListOfUserOrders)
                    {
                        if (!order.Pizza.ValidPizzaOrder(order.Pizza, currentListOfUserOrders))
                        {
                            Console.WriteLine("\nError, a pizza order for " + order.User.UserName +
                                              " is too expensive!\n" +
                                              "Current price: $" +
                                              order.Pizza.CalculatePizzaCost(order.Pizza.ingredientCount));
                        }
                    }
                }
                else
                {
                    Console.WriteLine("\nYou've ordered too much pizza. Sorry.");
                }
                UIPrompt();
                break;

            case "6":
                DisplayCurrentOrder(currentListOfUserOrders);
                break;

            default:
                Console.WriteLine("\nUnknown choice. Please try again.");
                UIPrompt();
                break;
            }
        }
コード例 #7
0
        private static List <Order> UsersListOfOrders()
        {
            bool ordering = true;

            var configBuilder = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = configBuilder.Build();

            var optionsBuilder = new DbContextOptionsBuilder <ContextPizza.pizzadatabaseContext>(); //DbContext?

            optionsBuilder.UseSqlServer(configuration.GetConnectionString("pizzadatabase"));
            var options    = optionsBuilder.Options;
            var dbContext  = new ContextPizza.pizzadatabaseContext(options);
            var repository = new pizzalibrary.pizzarepository(dbContext);

            while (ordering)
            {
                Console.WriteLine("\nPlease enter a username and user lastname for this new pizza.");
                string   user       = Console.ReadLine();
                string[] userinfo   = user.Split();
                bool     createUser = false;

                if (!MasterOrderList.SearchUser(masterList, userinfo))
                {
                    Console.Write("Would you like to add it? y/n\n");
                    string userCreateAnswer = Console.ReadLine();

                    switch (userCreateAnswer)
                    {
                    case "y":
                        Console.WriteLine("\nLogged in as " + userinfo[0] + ".");
                        createUser = true;
                        break;

                    case "n":
                        Console.WriteLine("\nUsername required to complete order.");
                        UsersListOfOrders();
                        break;

                    default:
                        Console.WriteLine("\nError: unknown input. Restarting order process.");
                        UsersListOfOrders();
                        break;
                    }
                }

                else if (userinfo.Length < 2)
                {
                    Console.WriteLine("\nInvalid format.");
                    UsersListOfOrders();
                }


                bool          chooseLocation = true;
                string        location       = "";
                StoreLocation s = new StoreLocation();

                while (chooseLocation)
                {
                    Console.WriteLine("\nPlease enter a location for which this pizza may be ordered.");
                    location = Console.ReadLine();

                    if (!MasterOrderList.SearchLocation(masterList, location))
                    {
                        Console.Write("\nSorry. Invalid location. Please try again.");
                    }

                    else if (s.CheckIfEmptyInventory(s))
                    {
                        Console.Write("\nThat location has an empty ingredient! Please order later.");
                    }

                    else
                    {
                        Console.WriteLine("\n" + location + " has been confirmed.");
                        s.Location = location;
                        User u = new User(userinfo[0], userinfo[1], location, DateTime.Today);
                        if (!createUser)
                        {
                            repository.Useradd(u);
                            repository.Save();
                        }

                        chooseLocation = false;
                    }
                }

                return(MakePizzas(currentListOfUserOrders, s, new User(userinfo[0], userinfo[1], location, DateTime.Now)));
            }

            return(currentListOfUserOrders);
        }
コード例 #8
0
        public static void Delete(int id)
        {
            Order thisOrder = GetOrder(id);

            MasterOrderList.Remove(thisOrder);
        }
コード例 #9
0
        private static List <Order> UsersListOfOrders()
        {
            bool ordering = true;

            while (ordering)
            {
                Console.WriteLine("\nPlease enter a username and user lastname for this new pizza.");
                string   user     = Console.ReadLine();
                string[] userinfo = user.Split();

                if (!MasterOrderList.SearchUser(masterList, userinfo))
                {
                    Console.Write("Would you like to add it? y/n\n");
                    string userCreateAnswer = Console.ReadLine();

                    switch (userCreateAnswer)
                    {
                    case "y":
                        Console.WriteLine("\nLogged in as " + userinfo[0] + ".");
                        break;

                    case "n":
                        Console.WriteLine("\nUsername required to complete order.");
                        UsersListOfOrders();
                        break;

                    default:
                        Console.WriteLine("\nError: unknown input. Restarting order process.");
                        UsersListOfOrders();
                        break;
                    }
                }

                else if (userinfo.Length < 2)
                {
                    Console.WriteLine("\nInvalid format.");
                    UsersListOfOrders();
                }

                bool          chooseLocation = true;
                string        location       = "";
                StoreLocation s = new StoreLocation();

                while (chooseLocation)
                {
                    Console.WriteLine("\nPlease enter a location for which this pizza may be ordered.");
                    location = Console.ReadLine();

                    if (!MasterOrderList.SearchLocation(masterList, location))
                    {
                        Console.Write("\nSorry. Invalid location. Please try again.");
                    }

                    else if (s.CheckIfEmptyInventory(s))
                    {
                        Console.Write("\nThat location has an empty ingredient! Please order later.");
                    }

                    else
                    {
                        Console.WriteLine("\n" + location + " has been confirmed.");
                        s.Location     = location;
                        chooseLocation = false;
                    }
                }

                return(MakePizzas(currentListOfUserOrders, s, new User(userinfo[0], userinfo[1], location, DateTime.Now)));
            }

            return(currentListOfUserOrders);
        }