private void SeedCustomers() { PotentialCustomer customer1 = new PotentialCustomer("Bob", "Smith"); _customerRepo.AddCustomer(customer1); PotentialCustomer customer2 = new PotentialCustomer("Jeremy", "Adams"); _customerRepo.AddCustomer(customer2); CurrentCustomer customer3 = new CurrentCustomer("Selina", "McCoy"); _customerRepo.AddCustomer(customer3); CurrentCustomer customer4 = new CurrentCustomer("Emily", "Arnold"); _customerRepo.AddCustomer(customer4); PastCustomer customer5 = new PastCustomer("Jim", "Williams"); _customerRepo.AddCustomer(customer5); PastCustomer customer6 = new PastCustomer("Henry", "Jones"); _customerRepo.AddCustomer(customer6); }
public void Update(PotentialCustomer potentialCustomer) { var entry = db.Entry(potentialCustomer); entry.State = EntityState.Modified; db.SaveChanges(); }
public void Arrange() { PastCustomer customer1 = new PastCustomer("Lina", "Smith"); _repo.AddCustomer(customer1); PotentialCustomer customer2 = new PotentialCustomer("Kel", "Smith"); _repo.AddCustomer(customer2); CurrentCustomer customer3 = new CurrentCustomer("Eric", "Smith"); _repo.AddCustomer(customer3); PastCustomer customer4 = new PastCustomer("Chris", "Forsythe"); _repo.AddCustomer(customer4); CurrentCustomer customer5 = new CurrentCustomer("Jacob", "Bullock"); _repo.AddCustomer(customer5); PotentialCustomer customer6 = new PotentialCustomer("Kate", "Harrison"); _repo.AddCustomer(customer6); }
public void AddPotential() { PotentialCustomer customer = new PotentialCustomer(); Console.WriteLine("Enter potential customer ID:"); if (Int32.TryParse(Console.ReadLine(), out _userInput)) { if (_customerRepo.GetCustomerById(_userInput) == null) { customer.Id = _userInput; } else { Console.WriteLine("This customer ID is already in use.\n" + "Press any key to try again with a different ID."); Console.ReadKey(); } } else { Console.WriteLine("Please enter a valid customer ID.\n" + "Press any key to try again."); Console.ReadKey(); } Console.WriteLine("Enter potential customer first name:"); customer.FirstName = Console.ReadLine(); Console.WriteLine("Enter potential customer last name:"); customer.LastName = Console.ReadLine(); Console.WriteLine("Enter potential customer email"); customer.Email = Console.ReadLine(); Console.Clear(); _customerRepo.AddCustomerToList(customer); }
private void ContinueButton_Click(object sender, RoutedEventArgs e) { Warning.Visibility = Visibility.Hidden; int number = 0; int postcode = 0; if (Name.Text != "" && Surname.Text != "" && Mail.Text != "" && int.TryParse(Phone.Text, out number) && Street.Text != "" && Town.Text != "" && int.TryParse(PostCode.Text, out postcode)) { PotentialCustomer Customer = new PotentialCustomer(); Customer.Name = Name.Text; Customer.Surname = Surname.Text; Customer.Mail = Mail.Text; Customer.Phone = number; Customer.Street = Street.Text; Customer.Town = Town.Text; Customer.PostCode = postcode; NavigationService ns = NavigationService.GetNavigationService(this); ns.Navigate(new FinishPage(Customer, TransportToSend, GoodsName, GoodsInCart, Piece)); } else { Warning.Visibility = Visibility.Visible; } }
public ActionResult Create(PotentialCustomer potentialCustomer) { if (ModelState.IsValid) { db.Add(potentialCustomer); return(RedirectToAction("Details", new { id = potentialCustomer.Id })); } return(View()); }
public void ExplicitOperatorTest_ShouldConvertCustomerType() { //Works PotentialCustomer potential = new PotentialCustomer(); CurrentCustomer current = (CurrentCustomer)potential; //Works Customer customer = _repo.GetCustomerByName("Lina", "Smith"); CurrentCustomer anotherCurrent = (CurrentCustomer)(potential as PotentialCustomer); }
public ActionResult Edit(PotentialCustomer potentialCustomer) { if (ModelState.IsValid) { db.Update(potentialCustomer); TempData["Message"] = "You have saved the customer contract!"; return(RedirectToAction("Details", new { id = potentialCustomer.Id })); } return(View(potentialCustomer)); }
public void UpdateCustomer(PotentialCustomer potentialCustomer) { using (var con = MyInsuranceDbConnection()) { con.Open(); con.Execute( @"UPDATE PotentialCustomer SET Name = @name, Phone = @phone, Email = @email, isCustomer = @isCustomer WHERE ID = @id", potentialCustomer); } }
public void SeedContent() { CurrentCustomer customerOne = new CurrentCustomer(1, "Konrad", "Haight", "*****@*****.**"); _customerRepo.AddCustomerToList(customerOne); PastCustomer customerTwo = new PastCustomer(2, "Nicole", "Haight", "*****@*****.**"); _customerRepo.AddCustomerToList(customerTwo); PotentialCustomer customerThree = new PotentialCustomer(3, "Ruby", "Haight", "none"); _customerRepo.AddCustomerToList(customerThree); }
private void AddNewPotentialCustomer() { Console.Clear(); string firstName = _prompt.PromptUserForFirstName(); string lastName = _prompt.PromptUserForLastName(); PotentialCustomer customer = new PotentialCustomer(firstName, lastName); _customerRepo.AddCustomer(customer); Console.Clear(); Console.WriteLine("Customer was successfully added..."); Console.ReadLine(); }
public void EditCustomer() { Console.WriteLine("Enter the customer ID:"); if (Int32.TryParse(Console.ReadLine(), out _userInput)) { if (_customerRepo.GetCustomerById(_userInput) != null) { ICustomer oldCustomer = _customerRepo.GetCustomerById(_userInput); ICustomer newCustomer; if (oldCustomer is CurrentCustomer) { newCustomer = new CurrentCustomer(); } else if (oldCustomer is PastCustomer) { newCustomer = new PastCustomer(); } else { newCustomer = new PotentialCustomer(); } Console.WriteLine("Enter the new customer ID"); newCustomer.Id = Int32.Parse(Console.ReadLine()); Console.WriteLine("Enter the new customer first name"); newCustomer.FirstName = Console.ReadLine(); Console.WriteLine("Enter the new customer last name"); newCustomer.LastName = Console.ReadLine(); Console.WriteLine("Enter the new customer email"); newCustomer.Email = Console.ReadLine(); _customerRepo.UpdateExistingCustomer(_userInput, newCustomer); Console.Clear(); } else { Console.WriteLine("Failed to locate customer\n" + "Press any key to try again."); Console.ReadKey(); Console.Clear(); } } else { Console.WriteLine("Please enter a valid customer ID\n" + "Press any key to try again."); Console.ReadKey(); Console.Clear(); } }
public ActionResult Delete(int id, PotentialCustomer potentialCustomer) { try { // TODO: Add delete logic here IPotentialCustomerRepository rep = new PotentialCustomerRepository(); rep.DeleteCustomer(id); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(PotentialCustomer potentialCustomer) { try { // TODO: Add insert logic here IPotentialCustomerRepository rep = new PotentialCustomerRepository(); rep.SaveCustomer(potentialCustomer); return(RedirectToAction("Index", "Home")); } catch { return(View()); } }
public PotentialCustomer GetCustomerByID(int id) { if (!File.Exists(DbFile)) { return(null); } using (var con = MyInsuranceDbConnection()) { con.Open(); PotentialCustomer result = con.Query <PotentialCustomer>( @"SELECT ID, Name, Phone, Email, isCustomer FROM PotentialCustomer WHERE ID = @id", new { id }).FirstOrDefault(); return(result); } }
public void SaveCustomer(PotentialCustomer potentialCustomer) { if (!File.Exists(DbFile)) { CreateDb(); CreateTable(); } using (var con = MyInsuranceDbConnection()) { con.Open(); con.Execute( @"INSERT INTO PotentialCustomer ( Name, Phone, Email, isCustomer ) VALUES ( @name, @phone, @email, @isCustomer )", potentialCustomer); } }
public void AddPotentalCustomerToList(PotentialCustomer customer) { _potentialCustomer.Add(customer); }
public FinishPage(PotentialCustomer Customer1, Transport TransportToSend, List <string> GoodsName, List <CartGoods> GoodsInCart, List <int> Piece1) { InitializeComponent(); Piece = Piece1; Address Address = new Address(); Address.Street = Customer1.Street; Address.Town = Customer1.Town; Address.PostNumber = int.Parse(Customer1.PostCode.ToString()); AddressDatabase.SaveItemAsync(Address); DebugMethod(); ContactInformation Contact = new ContactInformation(); Contact.Email = Customer1.Mail; Contact.Phone = Customer1.Phone; ContactInformationDatabase.SaveItemAsync(Contact); DebugMethod(); Customer Customer = new Customer(); Customer.AddressID = Address.AddressID; Customer.ContactInformationID = Contact.ContactInformationID; Customer.Name = Customer1.Name; Customer.Surname = Customer1.Surname; CustomerDatabase.SaveItemAsync(Customer); DebugMethod(); OrderTransport Transport = new OrderTransport(); Transport.TypeOfTransport = TransportToSend.Name; Transport.Price = TransportToSend.Price; OrderTransportDatabase.SaveItemAsync(Transport); DebugMethod(); Random r = new Random(); int rnd = r.Next(); int TotalPrice = 0; for (int i = 0; i < GoodsInCart.Count; i++) { TotalPrice += GoodsInCart[i].TotalPrice; } TotalPrice += Transport.Price; Order Order = new Order(); Order.CustomerID = Customer.CustomerID; Order.TransportID = Transport.TransportID; Order.OrderNumber = rnd; Order.OrderPrice = TotalPrice; OrderDatabase.SaveItemAsync(Order); DebugMethod(); Number.Text = Order.OrderNumber.ToString(); List <Customer> clist = new List <Customer>(); clist = CustomerDatabase.GetItemsAsync().Result; for (int i = 0; i < GoodsName.Count; i++) { OrderGoods OrderGoods = new OrderGoods(); OrderGoods.OrderID = Order.OrderID; Goods goods = GoodsDatabase.GetItemAsync(GoodsName[i]).Result; OrderGoods.GoodsQauntity = GoodsInCart[i].GoodsQauntity; OrderGoods.GoodsID = goods.GoodsID; OrderGoodsDatabase.SaveItemAsync(OrderGoods); DebugMethod(); } var ordergoods = OrderGoodsDatabase.GetItemsAsync().Result; var order = OrderDatabase.GetItemsAsync().Result; }
public void Add(PotentialCustomer potentialCustomer) { db.PotentialCustomer.Add(potentialCustomer); db.SaveChanges(); }