public Customer CreateNewCustomer(string name)
 {
     using (var log = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Console().WriteTo.File("../logs/logs.txt", rollingInterval: RollingInterval.Day).CreateLogger())
     {
         try
         {
             Customer newCustomer = new Customer(name);
             _customerBL.AddNewCustomer(newCustomer);
             Console.WriteLine("Sign up successful!");
             return(_customerBL.FindCustomerByName(name));
         }
         catch (Exception ex)
         {
             log.Warning(ex, ex.Message);
             return(AuthMenuFactory.GetMenu("signup").Start());
         }
     }
 }
        public Customer Start()
        {
            bool repeat = true;

            do
            {
                Console.WriteLine("Please log in before continuing");
                Console.WriteLine("Please enter your name");
                string   name            = Console.ReadLine();
                Customer currentCustomer = FindCustomerByName(name);
                if (currentCustomer is null)
                {
                    Console.WriteLine("Uh oh, we didn't find a match.");
                    Console.WriteLine("[1] Try Again");
                    Console.WriteLine("[2] Sign up");
                    Console.WriteLine("[0] Go Back");
                    string input = Console.ReadLine();
                    switch (input)
                    {
                    case "0":
                        break;

                    case "1":
                        break;

                    case "2":
                        AuthMenuFactory.GetMenu("signup").Start();
                        break;

                    default:
                        Console.WriteLine("I don't understand your input, please try again.");
                        break;
                    }
                }
                else
                {
                    Console.WriteLine($"Welcome {currentCustomer.Name}!");
                    return(currentCustomer);
                }
            } while(repeat);
            return(null);
        }
Esempio n. 3
0
        public void Start(Customer customer)
        {
            _currentCustomer = customer;
            bool repeat = true;

            do
            {
                string input;
                while (_currentCustomer is null)
                {
                    Console.WriteLine("Welcome to the Wild Side Story!");
                    Console.WriteLine("We specialize in sourdough supplies and products");
                    Console.WriteLine("Have you shopped with us before? [y/n]");
                    input = Console.ReadLine();
                    switch (input.ToLower())
                    {
                    case "y":
                        _currentCustomer = AuthMenuFactory.GetMenu("login").Start();
                        break;

                    case "n":
                        Console.WriteLine("Please sign up before continuing");
                        _currentCustomer = AuthMenuFactory.GetMenu("signup").Start();
                        break;

                    case "42":
                        _currentCustomer = new Customer("admin");
                        MenuFactory.GetMenu("admin").Start(_currentCustomer);
                        break;

                    default:
                        Console.WriteLine("I don't understand your input, please try again.");
                        break;
                    }
                }


                Console.WriteLine("What would you like to do today?");
                Console.WriteLine("[1] Browse Items");
                Console.WriteLine("[2] My Profile");
                Console.WriteLine("[0] Exit");
                input = Console.ReadLine();
                switch (input)
                {
                case "0":
                    Console.WriteLine("Goodbye, come back soon!");
                    repeat = false;
                    break;

                case "1":
                    MenuFactory.GetMenu("browse").Start(_currentCustomer);
                    break;

                case "2":
                    MenuFactory.GetMenu("profile").Start(_currentCustomer);
                    break;

                case "42":
                    MenuFactory.GetMenu("admin").Start(_currentCustomer);
                    break;

                default:
                    Console.WriteLine("I don't understand your input, please try again.");
                    break;
                }
            } while(repeat);
        }