static int AddCustomer(CustomerData customerData, DateTime CreatedDate) { Customer newCustomer = new Customer { FirstName = customerData.FirstName, LastName = customerData.LastName, Company = customerData.Company, EmailAddress = customerData.EmailAddress, WorkPhone = customerData.WorkPhone, HomePhone = customerData.HomePhone, Address = customerData.Address, City = customerData.City, State = customerData.State, ZipCode = customerData.ZipCode, Gender = customerData.Gender, BirthDate = customerData.BirthDate, FirstPurchaseDate = CreatedDate, LastPurchaseDate = CreatedDate }; SalesDbContext.Customers.Add(newCustomer); SalesDbContext.SaveChanges(); int newCustomerId = newCustomer.CustomerId; Console.Write("."); AddInvoice(newCustomerId, customerData.FirstInvoice, CreatedDate); return newCustomerId; }
public static CustomerData GetNextCustomer() { CustomerLocationData customerLocation = GetNextCustomerLocation(); string Address = GetNextAddress(); string City = customerLocation.City; string State = customerLocation.State; string ZipCode = customerLocation.ZipCode; string AreaCode = customerLocation.AreaCode; string WorkPhoneNumber = GetNextPhoneNumber(AreaCode); string HomePhoneNumber = GetNextPhoneNumber(AreaCode); string Gender = "F"; string invoiceType = "InPerson"; switch (CustomerGrowthPhase) { case 1: // phase 1 if (WingtipRandom.Next(1, 100) > 32) { Gender = "M"; } break; case 2: // phase 2 if (WingtipRandom.Next(1, 100) > 45) { Gender = "M"; } break; case 3: // phase 3 if (WingtipRandom.Next(1, 100) > 55) { Gender = "M"; } break; case 4: // phase 4 if (WingtipRandom.Next(1, 100) > 67) { Gender = "M"; } break; case 5: // phase 4 if (WingtipRandom.Next(1, 100) > 70) { Gender = "M"; } break; case 6: // phase 4 if (WingtipRandom.Next(1, 100) > 65) { Gender = "M"; } break; case 7: // phase 4 if (WingtipRandom.Next(1, 100) > 55) { Gender = "M"; } break; case 8: // phase 4 if (WingtipRandom.Next(1, 100) > 52) { Gender = "M"; } break; case 9: // phase 4 if (WingtipRandom.Next(1, 100) > 48) { Gender = "M"; } break; case 10: // phase 4 if (WingtipRandom.Next(1, 100) > 44) { Gender = "M"; } break; case 11: // phase 4 if (WingtipRandom.Next(1, 100) > 42) { Gender = "M"; } break; case 12: // phase 4 if (WingtipRandom.Next(1, 100) > 38) { Gender = "M"; } break; case 13: // phase 4 if (WingtipRandom.Next(1, 100) > 40) { Gender = "M"; } break; case 14: // phase 4 if (WingtipRandom.Next(1, 100) > 44) { Gender = "M"; } break; case 15: // phase 4 if (WingtipRandom.Next(1, 100) > 50) { Gender = "M"; } break; case 16: // phase 4 if (WingtipRandom.Next(1, 100) > 48) { Gender = "M"; } break; } string FirstName = ""; if (Gender.Equals("F")) { FirstName = GetNextFemaleFirstName(); } else { FirstName = GetNextMaleFirstName(); } string LastName = GetNextLastName(); string Company = GetNextCompany(); string EmailAddress = (FirstName + "." + LastName + "@" + Company + ".com").Replace(" ", "").Replace("'", ""); DateTime BirthDate = GetNextBirthDate(); if (State.Equals("FL")) { BirthDate = BirthDate.AddYears(-21); } if (State.Equals("AZ")) { BirthDate = BirthDate.AddYears(-12); } if (State.Equals("NM")) { BirthDate = BirthDate.AddYears(-9); } if (State.Equals("TX")) { BirthDate = BirthDate.AddYears(-7); } if (Gender.Equals("F")) { BirthDate = BirthDate.AddYears(-3); } List<InvoiceDetailData> invoiceDetails = new List<InvoiceDetailData>(); int ItemCount = WingtipRandom.Next(1, 4); double InvoiceAmount = 0; for (int index = 0; index < ItemCount; index++) { int productId = GetProductId(); ProductData product = Products[productId - 1]; int quantity = WingtipRandom.Next(1, 10); if (productId == 14) { int[] quantitySizes = { 10, 25, 25, 25, 100, 100, 100, 100, 100, 250, 250, 250, 500, 1000, 1000, 1000, 1000, 2500 }; int selection = WingtipRandom.Next(0, quantitySizes.Length - 1); quantity = quantitySizes[selection]; } double price = quantity * product.ListPrice; InvoiceAmount += price; invoiceDetails.Add(new InvoiceDetailData { ProductId = productId, Quantity = quantity, Price = price }); } InvoiceData FirstInvoice = new InvoiceData { InvoiceAmount = InvoiceAmount, InvoiceType = invoiceType, InvoiceDetails = invoiceDetails }; CustomerData newCustomer = new CustomerData { FirstName = FirstName, LastName = LastName, Company = Company, EmailAddress = EmailAddress, WorkPhone = WorkPhoneNumber, HomePhone = HomePhoneNumber, Address = Address, City = City, State = State, ZipCode = ZipCode, Gender = Gender, BirthDate = BirthDate, FirstInvoice = FirstInvoice }; customerCount += 1; return newCustomer; }