Beispiel #1
0
        /// <summary>
        /// Add a coffee product to the current customers order
        /// Multiplies given coffee product by amount purchased and passes to
        ///     AddToTotal_ method
        /// </summary>
        /// <param name="coffeeProduct"></param>
        /// <param name="quantity"></param>
        public void AddProductToOrder(CoffeeTypes coffeeProduct, int quantity)
        {
            Coffee coffee      = new Coffee();
            double coffeePrice = 0.00;

            using var context = new joshfordproject0Context(s_dbContextOptions);

            IQueryable <Product> menu = context.Products
                                        .OrderBy(x => x.ProductName);

            foreach (Product products in menu)
            {
                if (coffeeProduct.ToString().Equals(products.ProductName))
                {
                    coffeePrice = products.ProductPrice;
                }
            }


            /*
             * coffeePrice = double.Parse(context.Products
             *  .Select(x => x.ProductPrice)
             *  .Where(x => x.Equals(custCoffee))
             *  .ToString());
             */

            customerCoffee.Add(coffeeProduct);
            AddToTotalOrderPrice(coffeePrice * quantity);
        }
        /// <summary>
        /// Checks the given coffee products current amount in the store inventory
        /// </summary>
        /// <param name="productToCheck"></param>
        public void CheckProductInventory(Enum productToCheck)
        {
            using var context = new joshfordproject0Context(s_dbContextOptions);

            CoffeeTypes coffeeInvCheck = (CoffeeTypes)productToCheck;
            int         productAmount  = 0;

            // SQL Query for coffee Inventory

            Console.WriteLine($"Current amount of {coffeeInvCheck} is: {productAmount}");
        }
        /// <summary>
        /// Retrieves a given products price
        /// </summary>
        /// <param name="productToPrice"></param>
        public void GetProductPrice(Enum productToPrice)
        {
            using var context = new joshfordproject0Context(s_dbContextOptions);

            CoffeeTypes coffeeToPrice = (CoffeeTypes)productToPrice;

            var priceOfCoffee = context.Products
                                .Select(x => x.ProductPrice)
                                .Where(x => x.Equals(coffeeToPrice.ToString()));

            Console.WriteLine($"{coffeeToPrice}: $ {priceOfCoffee}");
        }
        public bool ValidateName(string custName)
        {
            using var context = new joshfordproject0Context(s_dbContextOptions);

            if (custName.Contains(" "))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        /// <summary>
        /// Passes the customer ID to an SQL query to check if the ID exists
        ///     in the customer database
        /// </summary>
        /// <param name="idToValidate"></param>
        /// <returns> boolean idIsValid </returns>
        public bool ValidateID(int idToValidate)
        {
            using var context = new joshfordproject0Context(s_dbContextOptions);

            if (idToValidate.Equals(context.Customers
                                    .Select(x => x.CustomerId)
                                    .Where(x => x.Equals(idToValidate))))
            {
                idIsValid = true;
            }

            return(idIsValid);
        }
Beispiel #6
0
        /// <summary>
        /// Finalizes the placed order by removing given products from the stores
        ///     inventory, adding order to Orders table and Employees/Customers
        ///     history tables
        /// </summary>
        public void PlaceOrder()
        {
            using var context = new joshfordproject0Context(s_dbContextOptions);
            var order = new Order
            {
                CustomerId = _customerID,
                EmployeeId = _employeeID,
                StoreId    = _storeID,
                OrderTotal = _currentOrderTotal
            };

            context.Orders.Add(order);

            context.SaveChanges();
        }
Beispiel #7
0
        /// <summary>
        /// Print the store Menu
        /// </summary>
        public static void PrintMenu()
        {
            using var context = new joshfordproject0Context(s_dbContextOptions);

            var totalMenuItems        = context.Products.Select(x => x.ProductId).Max();
            IQueryable <Product> menu = context.Products
                                        .OrderBy(x => x.ProductName);
            int menuLine = 1;

            foreach (Product products in menu)
            {
                Console.WriteLine($"{menuLine}: {products.ProductName}\t${products.ProductPrice}");
                menuLine++;
            }
            Console.WriteLine("\tMenu Choice:\n");
        }
Beispiel #8
0
        /// <summary>
        /// Add a food product to the current customers order
        /// Multiplies given food product by amount purchased and passes to
        ///     AddToTotal_ method
        /// </summary>
        /// <param name="foodProduct"></param>
        ///<param name="quantity"></param>
        public void AddProductToOrder(FoodTypes foodProduct, int quantity)
        {
            Food   food      = new Food();
            double foodPrice = 0.00;

            using var context = new joshfordproject0Context(s_dbContextOptions);

            IQueryable <Product> menu = context.Products
                                        .OrderBy(x => x.ProductName);

            foreach (Product products in menu)
            {
                if (foodProduct.ToString().Equals(products.ProductName))
                {
                    foodPrice = products.ProductPrice;
                }
            }

            customerFood.Add(foodProduct);
            AddToTotalOrderPrice(foodPrice * quantity);
        }
        public static void Main(string[] args)
        {
            // Let do this thing
            bool   validID       = false;
            bool   validResponse = false;
            string newOrReturn;
            int    menuOptions = 16;
            string customerFirstName;
            string customerLastName;
            int    customerID = 0;
            int    employeeID = 0;
            int    storeID    = 0;

            // Database Connection is established
            using var context = new joshfordproject0Context(s_dbContextOptions);

            // User Interface Begins
            Console.WriteLine("\t**********************************");
            Console.WriteLine("\t* Welcome to Rise 'N Grind Cafe! *");
            Console.WriteLine("\t**********************************");
            Console.WriteLine("\t*N: New Customer\n\t*S: Sign In");

            do
            {
                newOrReturn = Console.ReadLine().ToUpper();

                if (newOrReturn != "N" && newOrReturn != "S")
                {
                    Console.WriteLine("\tInvalid Input.");
                    Console.WriteLine("\tPlease select option from menu below");
                    Console.WriteLine("\t*N: New Customer\n\t*S: Sign In");
                }

                else
                {
                    validResponse = true;
                }
            } while (!validResponse);

            // Returning customer will input ID for ID validation
            // New customer will input name, and receive a customer ID
            if (newOrReturn == "S")
            {
                CustomerValidate customerToValidate = new CustomerValidate();

                Console.WriteLine("Please enter customer ID: ");
                customerID = int.Parse(Console.ReadLine());
                do
                {
                    if (customerToValidate.ValidateID(customerID))
                    {
                        validID = true;
                    }

                    else
                    {
                        Console.WriteLine("\tInvalid customer ID entered.");
                        Console.WriteLine("\tPlease enter a valid customer ID: ");
                        customerID = int.Parse(Console.ReadLine());
                    }
                } while (!validID);
            }

            else
            {
                CustomerValidate customerToValidate = new CustomerValidate();

                // New Customer enters first and last name for record keeping
                Console.WriteLine("\t--New Customer Information--");
                Console.WriteLine("\tPlease enter your first name: ");
                customerFirstName = Console.ReadLine();
                while (!customerToValidate.ValidateName(customerFirstName))
                {
                    Console.WriteLine("\tName cannot contain spaces");
                    Console.WriteLine("\tPlease enter a valid name: ");
                    customerFirstName = Console.ReadLine();
                }

                Console.WriteLine("\tPlease enter your last name: ");
                customerLastName = Console.ReadLine();
                while (!customerToValidate.ValidateName(customerLastName))
                {
                    Console.WriteLine("\tName cannot contain spaces");
                    Console.WriteLine("\tPlease enter a valid name: ");
                    customerLastName = Console.ReadLine();
                }

                CustomerC customerToAdd = new CustomerC();
                customerToAdd.AddNewCustomer(customerFirstName, customerLastName);

                /*
                 * if (customerToValidate.ValidateID(customerToAdd.CustID))
                 * {
                 *  validID = true;
                 * }
                 * else
                 * {
                 *  Console.WriteLine("--Customer Creation Error");
                 *  validID = false;
                 * }
                 */
            }

            // Create Customer Object
            CustomerC customer = new CustomerC(customerID);

            try
            {
                string menuSelection;

                do
                {
                    // Customer UI Initiation
                    OrderC order = new OrderC(customerID, employeeID, storeID);
                    Console.WriteLine("\t*******************");
                    Console.WriteLine("\t*   Order Menu    *");
                    Console.WriteLine("\t*******************");
                    Console.WriteLine("\t*A: Add Item to Order\n\t*E: Exit");
                    menuSelection = Console.ReadLine().ToUpper();
                    while (menuSelection != "A" && menuSelection != "E")
                    {
                        Console.WriteLine("\tInvalid Menu Selection.");
                        Console.WriteLine("\tPlease choose from the following:");
                        Console.WriteLine("\t*A: Add Item to Order\n\t*E: Exit");
                        menuSelection = Console.ReadLine().ToUpper();
                    }

                    if (menuSelection == "A")
                    {
                        Console.WriteLine("*******************");
                        Console.WriteLine("*      Menu       *");
                        Console.WriteLine("*******************");
                        OrderC.PrintMenu();
                        menuSelection = Console.ReadLine();
                        while (menuOptions < int.Parse(menuSelection) && int.Parse(menuSelection) < 0)
                        {
                            Console.WriteLine("\tInvalid Menu Selection");
                            Console.WriteLine("\tPlease select from the following:");
                            OrderC.PrintMenu();
                            menuSelection = Console.ReadLine();
                        }
                        var productSelection = OrderC.GetProductSelection(menuSelection);
                        if (productSelection.GetType().Equals(CoffeeTypes.Regular))
                        {
                            order.AddProductToOrder((CoffeeTypes)productSelection, 1);
                        }
                        else
                        {
                            order.AddProductToOrder((FoodTypes)productSelection, 1);
                        }
                    }
                    else if (menuSelection == "E")
                    {
                        Console.WriteLine("Thanks for stopping by!");
                    }
                    // Validation should prevent
                    else
                    {
                        Console.WriteLine("Applcation Closed due to validation error.");
                    }

                    order.PrintCurrentOrder();
                } while (menuSelection != "E");
            }
            catch (ApplicationException)
            {
                throw new ApplicationException("\tFatal Internal Error.\n\tExiting...");
            }
        }
        public static void Main(string[] args)
        {
            // Let do this thing
            bool   validResponse = false;
            string newOrReturn;
            string customerFirstName;
            string customerLastName;
            int    customerID = 0;
            int    employeeID = 1;
            int    storeID    = 1;

            // Database Connection is established
            using var context = new joshfordproject0Context(s_dbContextOptions);

            // User Interface implementation(html, css, js) will be added here
            Console.WriteLine("\t**********************************");
            Console.WriteLine("\t* Welcome to Rise 'N Grind Cafe! *");
            Console.WriteLine("\t**********************************");
            Console.WriteLine("\t*N: New Customer\n\t*S: Sign In");

            do
            {
                newOrReturn = Console.ReadLine().ToUpper();

                if (newOrReturn != "N" && newOrReturn != "S")
                {
                    Console.WriteLine("\tInvalid Input.");
                    Console.WriteLine("\tPlease select option from menu below");
                    Console.WriteLine("\t*N: New Customer\n\t*S: Sign In");
                }

                else
                {
                    validResponse = true;
                }
            } while (!validResponse);

            // Returning customer will input ID for ID validation
            // New customer will input name, and receive a customer ID
            // NEEDS REVISING, DOES NOT PROPERLY VALIDATE
            if (newOrReturn == "S")
            {
                CustomerC returnCustomer = new CustomerC();

                Console.WriteLine("Please enter customer ID: ");
                customerID     = int.Parse(Console.ReadLine());
                returnCustomer = returnCustomer.FindCustomerByID(customerID);
            }

            else
            {
                CustomerC newCustomer = new CustomerC();

                // New Customer enters first and last name for record keeping
                Console.WriteLine("\t--New Customer Information--");
                Console.WriteLine("\tPlease enter your first name: ");
                customerFirstName = Console.ReadLine();
                while (!newCustomer.ValidateName(customerFirstName))
                {
                    Console.WriteLine("\tName cannot contain spaces");
                    Console.WriteLine("\tPlease enter a valid name: ");
                    customerFirstName = Console.ReadLine();
                }

                Console.WriteLine("\tPlease enter your last name: ");
                customerLastName = Console.ReadLine();
                while (!newCustomer.ValidateName(customerLastName))
                {
                    Console.WriteLine("\tName cannot contain spaces");
                    Console.WriteLine("\tPlease enter a valid name: ");
                    customerLastName = Console.ReadLine();
                }

                CustomerC customerToAdd = new CustomerC();
                customerToAdd.AddNewCustomer(customerFirstName, customerLastName);
            }

            // Create Customer Object
            CustomerC customer = new CustomerC();

            try
            {
                OrderC order = new OrderC(customerID, employeeID, storeID);
                Menu.MenuUI(order);
            }
            catch (ApplicationException)
            {
                throw new ApplicationException("\tFatal Internal Error.\n\tExiting...");
            }
        }