private static Customer CreateCustomer(_CustomerType type) { var name = new Bogus.DataSets.Name(); var address = new Bogus.DataSets.Address(); var random = new Randomizer(); if (type == _CustomerType.Individual) { var phoneNo = new Bogus.DataSets.PhoneNumbers(); return(new IndividualCustomer() { FirstName = name.FirstName(), LastName = name.LastName(), CustomerType = type.ToString(), Street = address.StreetName(), City = address.City(), State = address.State(), Zipcode = int.Parse(address.ZipCode("######")), PhoneNo = int.Parse(phoneNo.PhoneNumber("########")), Age = random.Number(18, 100), Gender = (int)random.Enum <_Gender>() }); } else if (type == _CustomerType.Enterprise) { var companyName = new Bogus.DataSets.Company(); return(new EnterpriseCustomer() { FirstName = name.FirstName(), LastName = name.LastName(), CustomerType = type.ToString(), Street = address.StreetName(), City = address.City(), State = address.State(), Zipcode = int.Parse(address.ZipCode("######")), OrganizationName = companyName.CompanyName() + companyName.CompanySuffix(), OrganizationType = random.Enum <_OrganizationType>().ToString() }); } else { return(null); } }
private void PopulateInvoices() { var numInvoiceTypes = Enum.GetNames(typeof(InvoiceType)).Length; for (int i = 0; i < NUM_INVOICES; ++i) { var company = new Bogus.DataSets.Company(); var client = GetRandomElement(ClientService.AllItems); var items = new List <InvoiceItem>(); var payments = new List <InvoicePayment>(); var dueDate = DateTime.Now.AddDays(random.Next(-60, 90)); var invoiceDate = DateTime.Now.AddDays(random.Next(-270, 180)); Invoice invoice = new Invoice(-1, DateTime.Now, company.CatchPhrase(), client, items, payments, invoiceDate, dueDate, (InvoiceType)random.Next(numInvoiceTypes), new InvoiceStatus(dueDate, random.Next(2) == 1)); InvoiceService.CreateEntry(invoice); } }