public override void Generate()
        {
            var departmentsToBeAdded = new HashSet<string>();
            while (departmentsToBeAdded.Count != this.Count)
            {
                departmentsToBeAdded.Add(this.Random.GetRandomStringWithRandomLength(5, 50));
            }

            int index = 0;
            Console.WriteLine("Adding Manufacturers:");
            foreach (var departmentName in departmentsToBeAdded)
            {
                var newDepartment = new Department
                {
                    Name = departmentName,
                };

                this.Database.Departments.Add(newDepartment);

                if (index % 100 == 0)
                {
                    Console.Write(".");
                    Database.SaveChanges();
                }
                index++;
            }
            Console.WriteLine();
            Console.WriteLine("Departments Added!");
        }
Ejemplo n.º 2
0
        public override void Generate()
        {
            Console.WriteLine("Generating Departments");

            var uniqueDepartmentsNames = new HashSet<string>();

            while (uniqueDepartmentsNames.Count != this.Count)
            {
                uniqueDepartmentsNames.Add(this.Random.GetString(10, 50));
            }
            var index = 0;
            foreach (var uniqueName in uniqueDepartmentsNames)
            {
                var newDepartment = new Department
                {
                    Name = uniqueName
                };
                Db.Departments.Add(newDepartment);
                index++;
                if (index % 100 == 0)
                {
                    Console.Write(".");
                    Db.SaveChanges();
                }
            }

            Console.WriteLine("\nGenerating Departments Done!");
        }
Ejemplo n.º 3
0
        public void GenerateData(CompanyEntities data, IRandomGenerator random, int count)
        {
            for (var i = 0; i < count; i++)
            {
                var department = new Department
                {
                    Name = random.GetRandomString(random.GetRandomNumber(10, 50))
                };

                data.Departments.Add(department);
            }
        }
Ejemplo n.º 4
0
        public void GenerateData(CompanyEntities context, IRandomGenerator random, int count)
        {
            for (var i = 0; i < count; i++)
            {
                var name = random.GetString(10, 50);

                var department = new Department
                {
                    Name = name
                };

                context.Departments.Add(department);
            }
        }
        public void GenerateData(CompanyEntities data, IRandomGenerator random, int count)
        {
            var uniqueNames = new HashSet<string>();

            while (uniqueNames.Count < count)
            {
                uniqueNames.Add(random.GetRandomString(random.GetRandomNumber(10, 50)));
            }

            foreach (var uniqueName in uniqueNames)
            {
                var department = new Department { Name = uniqueName };
                data.Departments.Add(department);
            }
        }
        public override void Generate()
        {
            this.Logger.LogMessage("Adding departments");
            for (int i = 0; i < this.Count; i++)
            {
                var department = new Department
                {
                    Name = this.Random.GetRandomStringWithRandomLength(10, 50)
                };

                this.Database.Departments.Add(department);

                if (i % 100 == 0)
                {
                    this.Logger.Dot();
                    this.Database.SaveChanges();
                }
            }

            this.Logger.LogMessage(" Departments added!\n");
        }
Ejemplo n.º 7
0
 public Employee(string fname, string lname, string id, Department department, decimal salary)
     : base(fname, lname, id)
 {
     this.Salary = salary;
     this.Department = department;
 }
Ejemplo n.º 8
0
 public Developer(string fname, string lname, string id, Department department, decimal salary, IList<Projects> projects)
     : base(fname, lname, id, department, salary)
 {
     this.Projects = projects;
 }
 public SalesEmployee(string fname, string lname, string id, Department department, decimal salary, IList<ISale> sales)
     : base(fname, lname, id, department, salary)
 {
     this.Sales = sales;
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            var random = RandomDataGenerator.Instance;
            var db = new CompanyEntities();
            db.Configuration.AutoDetectChangesEnabled = false;

            Console.WriteLine("\nAdding departments");

            for (int i = 0; i < 100; i++)
            {
                var department = new Department
                {
                    Name = random.GetRandomStringWithRandomLength(10,50)
                };

                db.Departments.Add(department);

                if (i%100 == 0)
                {
                    Console.Write(".");
                    db.SaveChanges();
                }
            }
            db.SaveChanges();
            Console.WriteLine("\nDepartents added");

            Console.WriteLine("\nAdding employees");

            var departmentIds = db.Departments.Select(d => d.Id).ToList();
            for (int i = 0; i < 5000; i++)
            {
              var employee = new Employee
                {
                    FirstName = random.GetRandomStringWithRandomLength(5,20),
                    LastName = random.GetRandomStringWithRandomLength(5,20),
                    DepartmentId = departmentIds[random.GetRandomNumber(0, departmentIds.Count - 1)],
                    YearSalary = random.GetRandomNumber(50000,200000),
                    ManagerId = (i > 250) ? i - 1 :(int?)null // 4750 employees will have a manager (95%) :)
                                                                  // it is very stupid i know but I left it for last and forgot it
                };

              db.Employees.Add(employee);

              if (i % 100 == 0)
              {
                  Console.Write(".");
                  db.SaveChanges();
              }
            }
            db.SaveChanges();
            Console.WriteLine("\nEmployees added");

            Console.WriteLine("\nAdding Projects"); //For some reason it does not want to work
            var employeeIds = db.Employees.Select(e => e.Id).ToList();
            for (int i = 0; i < 1000; i++)
            {
                var project = new Project
                {
                    Name = "Project" + i.ToString(),
                };

                var count = random.GetRandomNumber(5, 20);

                for (int j = 0; j < count; j++)
                {
                    var projectEmployee = new ProjectsEmployee
                    {
                        EmployeeId = employeeIds[i+j],
                        ProjectId = i+1,
                        StartDate = new DateTime(random.GetRandomNumber(1980, 2005), random.GetRandomNumber(1, 12), random.GetRandomNumber(1, 28)),
                        EndDate = new DateTime(random.GetRandomNumber(2005, 2020), random.GetRandomNumber(1, 12), random.GetRandomNumber(1, 28))

                    };

                    project.ProjectsEmployees.Add(projectEmployee);
                }

                db.Projects.Add(project);

                if (i % 100 == 0)
                {
                    Console.Write(".");
                    db.SaveChanges();
                }
            }
            db.SaveChanges();
            Console.WriteLine("\nProjects added");

            Console.WriteLine("\nAdding Reports");
            var employeeIds2 = db.Employees.Select(d => d.Id).ToList();
            for (int i = 0; i < 5000; i++)
            {
                var empId = employeeIds2[i];

                for (int j = 0; j < 50; j++) // every empolyee gets 50 reports
                {
                    var report = new Report
                    {
                        EmployeeId = empId,
                        TimeOfReport = new DateTime(random.GetRandomNumber(1980, 2014), random.GetRandomNumber(1, 12), random.GetRandomNumber(1, 28))
                    };
                    db.Reports.Add(report);
                }
                Console.Write(".");
                db.SaveChanges();

            }
            db.SaveChanges();
            Console.WriteLine("\nReports added");

            db.Configuration.AutoDetectChangesEnabled = true;
        }
Ejemplo n.º 11
0
 public Manager(string fname, string lname, string id, Department department, decimal salary, IList<Employee> employres)
     : base(fname, lname, id, department, salary)
 {
     this.Employees = employres;
 }