Ejemplo n.º 1
0
        //GET - Customer
        public IActionResult Index(string searchString)
        {
            var customers = _storeRepo.GetCustomers();

            if (!String.IsNullOrEmpty(searchString))
            {
                string[] nameList  = searchString.Split(' '); ///[firstname, lastname]
                string   firstName = nameList[0];
                string   lastName  = nameList[1];
                customers = _storeRepo.GetCustomerByName(firstName, lastName);

                return(View(customers));
            }
            return(View(customers));
        }
Ejemplo n.º 2
0
        public void CustomerUI()
        {
            Console.WriteLine("Are You a returning customer?  y/n:");
            string input = null;

            while (input != "y" && input != "n")
            {
                Console.WriteLine("Enter 'Y' For Yes, 'N' for No :");
                input = GetUserInput().ToLower();
            }
            if (input == "n")
            {
                newUserUI();
            }
            else
            {
                oldUserUI();
            }

            try
            {
                Library.Customer customerCheck = storeRepo.GetCustomerByName(FirstName, LastName);
            }
            catch (Exception)
            {
                Console.WriteLine("There is no Customer By That Name.");
                Console.WriteLine();
                Console.WriteLine("Please Create A New User");
                newUserUI();
            }

            Library.Customer customer = storeRepo.GetCustomerByName(FirstName, LastName);
            customerId = customer.CustomerId;
            Console.Clear();
            Console.WriteLine($"Welcome\t{customer.FirstName}\t{customer.LastName}\t Email: {customer.Email}");
            Console.WriteLine();
            Console.WriteLine("Enter 'D' To Order From Default Store  or 'O' View Other Locations or 'X' to Exit: ");
            string store = GetUserInput().ToLower();

            while (store != "d" && store != "o" && store != "X")
            {
                Console.WriteLine("Enter 'D' for Default store, 'O' for Other locations or 'X' to Exit:");
                input = GetUserInput().ToLower();
            }
            if (store == "O")
            {
                GetuserLocation();
            }
            else if (store == "X")
            {
                Console.WriteLine("GoodBye!");
                return;
            }
            DataModel.Location location = storeRepo.GetLocationById(locationId);
            Console.WriteLine($"Your Store Location is \t{location.Name}\t{location.Address}\t{location.City}\t{location.State}");
            Console.WriteLine();
            Console.WriteLine("Here is the Current Inventory of This Store");
            GetInventory(locationId);
            Console.WriteLine();
            Console.WriteLine(" Enter 'o' to order an Item or Enter 'e' to Exit:");
            string userOrder = GetUserInput();

            while (userOrder != "o" && userOrder != "e")
            {
                Console.WriteLine("Enter 'o' to order an Item or Enter 'e' to Exit:");
                userOrder = GetUserInput().ToLower();
            }
            if (userOrder == "e")
            {
                Console.WriteLine($"Good Bye");
                return;
            }
            else
            {
                GetUserOrder();
            }
            bool keepOrdering = true;

            while (keepOrdering)
            {
                Console.WriteLine("Order another item? y/n:");
                string moreOrders = GetUserInput().ToLower();
                while (moreOrders != "y" && moreOrders != "n")
                {
                    Console.WriteLine("Enter 'Y' to keep ordering or 'N' to exit :");
                    moreOrders = GetUserInput().ToLower();
                }

                if (moreOrders == "y")
                {
                    GetUserOrder();
                }
                else
                {
                    GetCustomerOrder();
                    Console.WriteLine($"Order Total:   ${total}");
                    Console.WriteLine($"Good Bye");
                    keepOrdering = false;
                }
            }
        }