/// <summary> /// Adds buyer to the database and returns added buyer /// </summary> /// <param name="buyer"> buyer to be added to the database</param> /// <returns>buyer added to the database</returns> public DogBuyer AddBuyer(DogBuyer buyer) { Entity.DogBuyer dogBuyer = new Entity.DogBuyer(); dogBuyer.UserName = buyer.Name; dogBuyer.PhoneNumber = buyer.PhoneNumber; dogBuyer.UserAddress = buyer.Address; _context.DogBuyers.Add(dogBuyer); _context.SaveChanges(); return(buyer); }
/// <summary> /// finds a customer and prints if found /// </summary> private void FindCustomer() { long phoneNumber = validation.ValidatePhone("Enter the phone number for the customer you're looking for"); DogBuyer dogBuyer = _buyerBL.FindUser(phoneNumber); if (dogBuyer == null) { Console.WriteLine("User not found! Try adding user."); } else { Console.WriteLine("User Info: " + dogBuyer.Name + " located in " + dogBuyer.Address); } }
/// <summary> /// allows customer to be added to database /// </summary> private void AddCustomer() { long phone = validation.ValidatePhone("Hello, please enter your phone number in the format 1234567890"); _dogBuyer = _buyerBL.FindUser(phone); if (_dogBuyer == null) { string name = validation.ValidateName("Please enter your name in the format Firstname Lastname"); string address = validation.ValidateAddress("Please enter your address in the format CityName, ST"); _dogBuyer = new DogBuyer(name, address, phone); _buyerBL.AddBuyer(_dogBuyer); } else { Console.WriteLine("User is already in database."); } }
public DogBuyer AddBuyer(DogBuyer user) { return(_repoDS.AddBuyer(user)); }
/// <summary> /// Method to call on start of menu /// </summary> public void OnStart() { long phone = validation.ValidatePhone("Hello, please enter your phone number in the format 1234567890"); _dogBuyer = _buyerBL.FindUser(phone); if (_dogBuyer == null) { string name = validation.ValidateName("Please enter your name in the format Firstname Lastname"); string address = validation.ValidateAddress("Please enter your address in the format CityName, ST"); _dogBuyer = new DogBuyer(name, address, phone); _buyerBL.AddBuyer(_dogBuyer); } bool repeat = true; do { Console.WriteLine("How can I Help you?"); Console.WriteLine("[0] See list of stores"); Console.WriteLine("[1] See a shop's inventory"); Console.WriteLine("[2] Order a dog"); Console.WriteLine("[3] Add a customer"); Console.WriteLine("[4] Find a customer"); Console.WriteLine("[5] See a customer's orders"); Console.WriteLine("[6] See a list of all customers"); Console.WriteLine("[7] Find a customer by name"); Console.WriteLine("Enter anything else to return"); string input = Console.ReadLine(); switch (input) { case "0": foreach (StoreLocation s in ViewStoreList()) { Console.WriteLine(s.ToString()); } break; case "1": ViewStoreInv(); break; case "2": OrderDog(); break; case "3": AddCustomer(); break; case "4": FindCustomer(); break; case "5": ViewOrders(); break; case "6": ViewCustomers(); break; case "7": ViewCustomerByName(); break; default: repeat = false; break; } }while(repeat); }