Exemplo n.º 1
0
        public dynamic GetReportData()
        {
            // Generating employee list
            var employees = Enumerable
                            .Range(0, NumberData.GetNumber(10, 50))
                            .Select(i =>
            {
                dynamic newEmployee       = new ExpandoObject();
                newEmployee.BirthDate     = DateTimeData.GetDatetime(new DateTime(1973, 1, 1), new DateTime(1997, 12, 1));
                newEmployee.FirstName     = NameData.GetFirstName();
                newEmployee.LastName      = NameData.GetSurname();
                newEmployee.Company       = NameData.GetCompanyName();
                newEmployee.Email         = NetworkData.GetEmail();
                newEmployee.PhoneNumber   = PhoneNumberData.GetInternationalPhoneNumber();
                newEmployee.Address       = string.Format("{0} {1} {2}\n{3},{4} {5}", PlaceData.GetStreetName(), PlaceData.GetStreetNumber(), PlaceData.GetAddress(), PlaceData.GetCity(), PlaceData.GetState(), PlaceData.GetZipCode());
                newEmployee.PersonalQuote = TextData.GetSentences(5);
                // NOTE: Even though ExpandoObject is compatible with IDictionary<string,object>,
                //       The template engine only accepts Dictionary<string,object>
                return(new Dictionary <string, object>(newEmployee));
            })
                            .ToList();

            dynamic reportData = new ExpandoObject();

            reportData.Employees = employees;
            return(reportData);
        }
Exemplo n.º 2
0
        protected override void Seed(AppWithEF.DatabaseContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.

            if (!context.Albums.Any())
            {
                for (int i = 0; i < 10; i++)
                {
                    context.Albums.Add(new Album
                    {
                        Name        = NameData.GetCompanyName(),
                        Description = TextData.GetSentence(),
                        Duration    = NumberData.GetNumber(),
                        Author      = NameData.GetFullName()
                    });
                }

                context.SaveChanges();
            }
            else
            {
                context.Albums.ToList().ForEach(x =>
                {
                    if (x.Duration == null || x.Duration == 0)
                    {
                        x.Duration = NumberData.GetNumber(500, 1000);
                    }

                    if (string.IsNullOrEmpty(x.Author))
                    {
                        x.Author = NameData.GetFullName();
                    }
                });

                if (context.ChangeTracker.HasChanges())
                {
                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 3
0
        public List <Album> GetAlbums()
        {
            if (_albums == null)
            {
                _albums = new List <Album>();

                for (int i = 0; i < 10; i++)
                {
                    _albums.Add(new Album
                    {
                        Id    = i,
                        Name  = NameData.GetCompanyName(),
                        Desc  = TextData.GetSentence(),
                        Genre = EnumData.GetElement <AlbumGenre>()
                    });
                }
            }

            return(_albums);
        }
Exemplo n.º 4
0
        private static void CreateFakeData(AlbumManager albumManager)
        {
            if (albumManager.Query().Any() == false)
            {
                for (int i = 0; i < 5; i++)
                {
                    albumManager.Create(new Album
                    {
                        Name    = NameData.GetCompanyName(),
                        Price   = (decimal)NumberData.GetDouble() * NumberData.GetNumber(100, 4000),
                        IsSales = BooleanData.GetBoolean(),
                        Year    = NumberData.GetNumber(1980, DateTime.Now.Year)
                    });
                }

                Console.WriteLine("Sample data created. Please enter for continue..");
                Console.WriteLine();
                Console.ReadKey();
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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);
            }
        }