//works static ICustomer GetCustomerFromDB(caproj0Context context, string phEntered, ILocation store) { var cust = context.Customer.FirstOrDefault(c => c.Phone == phEntered); //customer exist? if (cust == null) { Console.WriteLine("Invalid customer:"); return(null); } var theCust = GetTheCustomer(store, phEntered); //add to the local list if not already in list. if (theCust == null) { store.AddClient(new business_logic.Customer(cust.Fname, cust.Lname, cust.Phone, cust.CustomerPw)); } //return from the local list return(GetTheCustomer(store, phEntered)); }
static void MakeNewCustomer(caproj0Context context, ILocation store) { Console.Clear(); //get sample input. Console.Write("First Name: \t"); string fn = Console.ReadLine(); Console.Write("Last Name: \t"); string ln = Console.ReadLine(); Console.Write("Cell Phone Number: \t"); string cn = Console.ReadLine(); // basic cybersecurity: have them answer it twice, compare, then use another method to record the password. // Not encrypted (for now) Console.Write("Enter a Password: \t"); string pw1 = Console.ReadLine(); Console.Write("Confirm your Password: \t"); string pw2 = Console.ReadLine(); //for old time's sake string RealDeal = new String(""); while (true) { if (pw1 != pw2) { Console.WriteLine("Password Entries Do Not Match"); Console.Write("Enter a Password: "******"Confirm your Password: "******"Welcome:{ customer.FName } {customer.LName } at {customer.PhoneNum }" + "\nIs your information correct?\n 1: Yes, 2: No\n\n"); string read = Console.ReadLine(); bool sentinalConf = false; // //if it is a valid entry //added to location's client-list //otherwise is corrected //confirmed as valid if (read == "1") { Console.Clear(); sentinalConf = true; Console.WriteLine($"Thank You, {customer.FName}, \nPlease log in at the main menu\n\nRecording your information..."); //mirror to DB //fn, ln, cn, RealDeal AddCustToDB(context, fn, ln, cn, RealDeal); //is passed by reference, so all changes from here on out affect the reference. //DATABSE INTEGRATION: before store stores a list of customer. // now database gets a new entry. store.AddClient(customer); Thread.Sleep(3000); } //enter and correct customer info or exit to main menu. while (!sentinalConf) { Console.Clear(); Console.WriteLine("Please correct your information"); Thread.Sleep(1000); string choice = "NOPE"; Console.WriteLine($"Enter a Number for Correction or 0 to finish: " + $"\n1: { customer.FName } " + $"\n2. { customer.LName } " + $"\n3. { customer.PhoneNum } " + "\n\nEnter 9 to Cancel and Exit"); choice = Console.ReadLine(); switch (choice) { case "1": Console.Clear(); Console.WriteLine("Re-Enter your first-name: "); customer.FName = Console.ReadLine(); break; case "2": Console.Clear(); Console.WriteLine("Re-Enter your last-name: "); customer.LName = Console.ReadLine(); break; case "3": Console.Clear(); Console.WriteLine("Re-Enter your phone-number: "); customer.PhoneNum = Console.ReadLine(); break; case "0": sentinalConf = true; Console.Clear(); Console.WriteLine($"Thank You, {customer.FName}, \nPlease log in at the main menu\nRecording Your Information..."); //confirmed as Factual so, add to the client-list. store.AddClient(customer); //mirror to DB from here AFTER corrections //fn, ln, cn, RealDeal AddCustToDB(context, fn, ln, cn, RealDeal); Thread.Sleep(3000); break; default: //any other entry other than relevant choices lead to no-record and exit. customer = null; Console.Clear(); Console.WriteLine($"Thank You, \nCanceling and Returning to Main Menue..."); sentinalConf = true; break; } }//end while loop }