示例#1
0
        private List <Customer> BuildCustomerList(int nCustomers)
        {
            var customers = new List <Customer>();
            var names     = new List <string>();

            for (var i = 1; i <= nCustomers; i++)
            {
                var name = DataSeedService.MakeUniqueCustomerName(names);
                names.Add(name);

                customers.Add(new Customer
                {
                    Id    = i,
                    Name  = name,
                    Email = DataSeedService.MakeCustomerEmail(name),
                    State = DataSeedService.GetRandomState()
                });
            }

            return(customers);
        }
示例#2
0
        private List <Order> BuildOrderList(int nOrders)
        {
            var orders = new List <Order>();
            var rand   = new Random();

            for (var i = 1; i <= nOrders; i++)
            {
                var randCustomerId = rand.Next(1, _context.Customers.Count());
                var placed         = DataSeedService.GetRandomOrderPlaced();
                var completed      = DataSeedService.GetRandomOrderCompleted(placed);

                orders.Add(new Order
                {
                    Id        = i,
                    Customer  = _context.Customers.First(c => c.Id == randCustomerId),
                    Total     = DataSeedService.GetRandomOrderTotal(),
                    Placed    = placed,
                    Completed = completed
                });
            }

            return(orders);
        }