Example #1
0
 //Sixth LOG OUT menu
 private static void LogOut()
 {
     if (currentCustomer == null)
     {
         Console.WriteLine("You were't logged in!");
     }
     else
     {
         currentCustomer = null;
         Console.WriteLine("\r\nLog out SUCCESFUL!\r\n");
     }
 }
Example #2
0
        //Second Choose customer menu
        private static void ChooseCustomer()
        {
            if (currentCustomer == null)
            {
                if (customers.Count == 0)
                {
                    Console.WriteLine("\r\nNo registered clients found!\r\nPlease create a new one.\r\n");
                    MenuCreateClient();
                }
                if (customers.Count == 1)
                {
                    currentCustomer = customers[0];
                }
                else
                {
                    Console.WriteLine("Choose customer's number.");
                    int i = 0;
                    foreach (var customer in customers)
                    {
                        Console.WriteLine("| {0} for {1} | ", i, customers[i]);
                        i++;
                    }

                    //Check for correct customer number
                    int customerNumber = -1;
                    bool isNumber = int.TryParse(Console.ReadLine(), out customerNumber);
                    bool isNumberCorrect = customerNumber >= 0 & customerNumber < customers.Count;
                    do
                    {
                        if (isNumberCorrect)
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Choose correct customer's number.");
                            isNumber = int.TryParse(Console.ReadLine(), out customerNumber);
                        }
                        isNumberCorrect = customerNumber >= 0 & customerNumber < customers.Count;
                    }
                    while (isNumber & !isNumberCorrect);
                    currentCustomer = customers[customerNumber];
                }

                Console.WriteLine("You are browsing as {0}.\r\n", currentCustomer.Name);
            }
        }