Ejemplo n.º 1
0
        protected override void Seed(ZeroDbContext context)
        {
            var admin = new ApplicationUser()
            {
                Id        = 1,
                FirstName = "Ekin",
                LastName  = "Memiş",
                Email     = "*****@*****.**",
                Password  = "******",
                Active    = true,
                Deleted   = false,
            };

            context.ApplicationUser.AddOrUpdate(admin);

            Random rnd = new Random();

            for (int i = 0; i < 100; i++)
            {
                Customer customer = new Customer
                {
                    Id                    = i,
                    Active                = true,
                    DateOfBirth           = DateTimeData.GetDatetime(),
                    Deleted               = false,
                    Email                 = NetworkData.GetEmail(),
                    FirstName             = NameData.GetFirstName(),
                    LastName              = NameData.GetSurname(),
                    PalceOfBirth          = FakeData.PlaceData.GetAddress(),
                    PhoneNumber           = PhoneNumberData.GetPhoneNumber(),
                    TurkishIdentityNumber = NumberData.GetDouble().ToString(),
                };
                context.Customer.AddOrUpdate(customer);

                Employee employee = new Employee
                {
                    Id                    = i,
                    Active                = true,
                    DateOfBirth           = DateTimeData.GetDatetime(),
                    Deleted               = false,
                    Email                 = NetworkData.GetEmail(),
                    FirstName             = NameData.GetFirstName(),
                    LastName              = NameData.GetSurname(),
                    PalceOfBirth          = FakeData.PlaceData.GetAddress(),
                    PhoneNumber           = PhoneNumberData.GetPhoneNumber(),
                    TurkishIdentityNumber = NumberData.GetDouble().ToString(),
                    Sallary               = NumberData.GetNumber(),
                    Title                 = NameData.GetCompanyName()
                };
                context.Employee.AddOrUpdate(employee);

                AppointmentType appointmentType = new AppointmentType
                {
                    Id = i,
                    DefaultSeanceQuantity = NumberData.GetNumber(1, 10),
                    Name    = TextData.GetAlphabetical(5),
                    Deleted = false,
                };
                context.AppointmentType.AddOrUpdate(appointmentType);

                Appointment appointment = new Appointment
                {
                    Id                  = i,
                    Deleted             = false,
                    StartDate           = DateTimeData.GetDatetime(),
                    EndDate             = DateTimeData.GetDatetime(),
                    Price               = NumberData.GetNumber(),
                    PriceIncludedTax    = NumberData.GetNumber(),
                    Name                = TextData.GetAlphabetical(5),
                    AppointmentStatusId = 0,
                    AppointmentTypeId   = rnd.Next(100),
                };
                context.Appointment.AddOrUpdate(appointment);
            }
        }
Ejemplo n.º 2
0
        public void Generate()
        {
            var random = new Random();

            client.PutIndex(new RavenDocumentsByEntityName());
            client.PutIndex(new OrdersByCompany());
            client.PutIndex(new OrdersTotals());
            client.PutIndex(new ProductSales());
            client.PutIndex(new OrdersByEmployeeAndCompany());
            client.PutIndex(new OrdersByEmployeeAndCompanyReduce());

            var nextOrderId    = 1;
            var nextCompanyId  = 1;
            var nextProductId  = 1;
            var nextEmployeeId = 1;

            for (var it = 0; it < numberOfIterations; it++)
            {
                var entities = new List <object>();

                for (var i = 0; i < NumberOfOrdersPerIteration; i++)
                {
                    entities.Add(new Order
                    {
                        Id      = "orders/" + nextOrderId++,
                        Company = "companies/" + random.Next(1, ExpectedNumberOfCompanies - 1),
                        Lines   = CollectionData.GetElement(10, new List <OrderLine>
                        {
                            new OrderLine
                            {
                                Product      = "products/" + random.Next(1, ExpectedNumberOfProducts - 1),
                                Quantity     = random.Next(1, 100),
                                PricePerUnit = random.Next(1000)
                            }
                        }).ToList(),
                        Employee  = "employees/" + random.Next(1, ExpectedNumberOfEmployees - 1),
                        OrderedAt = DateTimeData.GetDatetime(),
                        RequireAt = DateTime.UtcNow.AddDays(7),
                        ShipTo    = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfCompaniesPerIteration; i++)
                {
                    entities.Add(new Company
                    {
                        Id      = "companies/" + nextCompanyId++,
                        Name    = NameData.GetCompanyName(),
                        Fax     = PhoneNumberData.GetInternationalPhoneNumber(),
                        Address = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfEmployeesPerIteration; i++)
                {
                    entities.Add(new Employee
                    {
                        Id        = "employees/" + nextEmployeeId++,
                        Birthday  = DateTimeData.GetDatetime(),
                        FirstName = NameData.GetFirstName(),
                        LastName  = NameData.GetSurname(),
                        HomePhone = PhoneNumberData.GetPhoneNumber(),
                        HiredAt   = DateTimeData.GetDatetime(),
                        Address   = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfProductsPerIteration; i++)
                {
                    entities.Add(new Product
                    {
                        Id           = "products/" + nextProductId++,
                        Category     = TextData.GetAlphabetical(5),
                        Name         = NameData.GetSurname(),
                        Discontinued = BooleanData.GetBoolean(),
                        PricePerUnit = NumberData.GetNumber()
                    });
                }

                client.PutEntities(entities);
            }
        }