Ejemplo n.º 1
0
        /// <summary> Method to add a new User to the DB </summary>
        /// <params> Takes in a repository object</params>
        public void newCustomer(Repository repo)
        {
            IWrite.writeStatement("Great! Welcome to Acme! Let's get you signed up. What is your first name?");
            string newFirstName = Console.ReadLine();

            IWrite.writeStatement("What is your last name?");
            string newLastName = Console.ReadLine();

            DataAccessLibrary.Customer newCustomer = new DataAccessLibrary.Customer();
            newCustomer.FirstName = newFirstName;
            newCustomer.LastName  = newLastName;
            repo.addCustomer(newCustomer);
            activeUser = repo.getcustomerByName(newCustomer).FirstOrDefault();
            IWrite.writeStatement($"You have been sucesffuly added, {activeUser.FirstName} {activeUser.LastName}");
        }
Ejemplo n.º 2
0
        /// <summary> Method to check if a customer exists in the DB and sets them to the active user </summary>
        /// <params> Takes in a repository object</params>
        public void returningCustomer(Repository repo)
        {
            IWrite.writeStatement("What is your name? (No Middle)");
            string userName = Console.ReadLine().Trim();

            string[] customerSearchName = userName.Split(" ");
            DataAccessLibrary.Customer searchCustomer = new DataAccessLibrary.Customer();
            searchCustomer.FirstName = customerSearchName[0];
            searchCustomer.LastName  = customerSearchName[1];
            activeUser = repo.getcustomerByName(searchCustomer).FirstOrDefault();
            if (activeUser != null)
            {
                IWrite.writeStatement($"Welcome back {activeUser.FirstName} {activeUser.LastName}!");
            }
            else
            {
                IWrite.writeStatement("I'm sorry, we couldn't find your information.");
            }
        }