Example #1
0
        public virtual void SetUp()
        {
            unitOfWork        = new UnitOfWork(sessionFactory);
            studentsCreator   = new StudentCreator(unitOfWork, repositoriesFactory);
            studentsProvider  = new StudentsProvider(unitOfWork, repositoriesFactory);
            studentDestructor = new StudentDestructor(unitOfWork, repositoriesFactory);
            studentImporter   = new CsvStudentsImporter(studentsCreator);

            modesCreator  = new ModesCreator(unitOfWork, repositoriesFactory);
            modesProvider = new ModesProvider(unitOfWork, repositoriesFactory);

            companyCreator    = new CompanyCreator(unitOfWork, repositoriesFactory);
            companyUpdater    = new CompanyUpdater(unitOfWork, repositoriesFactory);
            companyDestructor = new CompanyDestructor(unitOfWork, repositoriesFactory);
            companiesProvider = new CompaniesProvider(unitOfWork, repositoriesFactory);

            offerCreator    = new OfferCreator(unitOfWork, repositoriesFactory);
            offerUpdater    = new OfferUpdater(unitOfWork, repositoriesFactory);
            offerDestructor = new OfferDestructor(unitOfWork, repositoriesFactory);
            offerProvider   = new OffersProvider(unitOfWork, repositoriesFactory);

            courseCreator    = new CourseCreator(unitOfWork, repositoriesFactory);
            courseProvider   = new CoursesProvider(unitOfWork, repositoriesFactory);
            courseUpdater    = new CourseUpdater(unitOfWork, repositoriesFactory, authenticationService);
            courseDestructor = new CourseDestructor(unitOfWork, repositoriesFactory);

            departmentCreator    = new DepartmentCreator(unitOfWork, repositoriesFactory);
            departmentProvider   = new DepartmentsProvider(unitOfWork, repositoriesFactory);
            departmentDestructor = new DepartmentDestructor(unitOfWork, repositoriesFactory);
            departmentUpdater    = new DepartmentUpdater(unitOfWork, repositoriesFactory);

            employeesDestructor = new EmployeeDestructor(unitOfWork, this.repositoriesFactory, this.authenticationService);
            employeesProvider   = new EmployeesProvider(unitOfWork, repositoriesFactory);
            employeeCreator     = new EmployeeCreator(unitOfWork, this.authenticationService, this.repositoriesFactory);
            employeesUpdater    = new EmployeeUpdater(unitOfWork, this.repositoriesFactory, this.authenticationService);

            templateCreator    = new TemplateCreator(unitOfWork, repositoriesFactory);
            templateDestructor = new TemplateDestructor(unitOfWork, repositoriesFactory);
            templateProvider   = new TemplatesProvider(unitOfWork, repositoriesFactory);

            offerTypeCreator  = new OfferTypeCreator(unitOfWork, repositoriesFactory);
            offerTypeProvider = new OfferTypeProvider(unitOfWork, repositoriesFactory);

            universityDetailsCreator  = new UniversityDetailsCreator(unitOfWork, repositoriesFactory);
            universityUpdater         = new UniversityDetailsUpdater(unitOfWork, repositoriesFactory);
            universityDetailsProvider = new UniversityDetailsProvider(unitOfWork, repositoriesFactory);
        }
Example #2
0
        public void Generate()
        {
            PrepareData();

            using (var unitOfWork = new UnitOfWork(_sessionFactory))
            {
                var departmentCreator = new DepartmentCreator(unitOfWork, _repositoriesFactory);
                var courseCreator     = new CourseCreator(unitOfWork, _repositoriesFactory);
                var courseUpdater     = new CourseUpdater(unitOfWork, _repositoriesFactory, _auth);
                var employeesCreator  = new EmployeeCreator(unitOfWork, _auth, _repositoriesFactory);
                var studentCreator    = new StudentCreator(unitOfWork, _repositoriesFactory);
                var studentsImporter  = new CsvStudentsImporter(studentCreator);
                var modesProvider     = new ModesProvider(unitOfWork, _repositoriesFactory);

                var mode = modesProvider.GetModes().First();

                EmployeeCreateStatus status;
                Course rootCourse = null;

                var departments = _document.Descendants("department").ToList();

                foreach (var d in departments)
                {
                    var dName     = d.Attribute("name").Value;
                    var deparment = departmentCreator.Create(dName);

                    var courses = d.Descendants("course").ToList();
                    foreach (var c in courses)
                    {
                        var cName = c.Attribute("name").Value;
                        Console.WriteLine(cName);
                        var course = courseCreator.Create(cName, deparment);

                        if (rootCourse == null)
                        {
                            rootCourse = course;
                        }

                        var employees = c.Descendants("employee").ToList();
                        foreach (var e in employees)
                        {
                            var userName  = e.Attribute("name").Value;
                            var manager   = bool.Parse(e.Attribute("manager").Value);
                            var admin     = bool.Parse(e.Attribute("administrator").Value);
                            var moderator = bool.Parse(e.Attribute("moderator").Value);

                            var firstName = userName.Split('.')[0];
                            var lastName  = userName.Split('.')[1];
                            var mail      = string.Format("{0}@mailinator.com", userName);
                            var employee  = employeesCreator.Create(userName, firstName, lastName, "qwerty", mail, "qwerty", "qwerty", moderator, false, admin, course, out status);

                            if (manager)
                            {
                                courseUpdater.SetManager(course, employee);
                            }
                        }

                        using (var streamReader = new StreamReader("Data/studenci.txt"))
                        {
                            studentsImporter.Import(streamReader.BaseStream, course, mode);
                        }
                    }
                }

                employeesCreator.Create("root", "Jan", "Kowalski", "qwerty", "*****@*****.**", "qwerty", "qwerty", true, true, true, rootCourse, out status);

                Console.WriteLine("\n\nOferty\n\n");
                var companyCreator     = new CompanyCreator(unitOfWork, _repositoriesFactory);
                var offerTypesProvider = new OfferTypeProvider(unitOfWork, _repositoriesFactory);
                var offerCreator       = new OfferCreator(unitOfWork, _repositoriesFactory);

                var companies = _document.Descendants("company").ToList();
                int counter   = 0;
                foreach (var c in companies)
                {
                    counter++;

                    var    companyName = c.Attribute("name").Value;
                    var    city        = c.Attribute("city").Value;
                    var    url         = string.Format("http://www.{0}.pl", companyName);
                    string postalCode  = string.Format("43-3{0}", (counter + 5) * 11);
                    var    street      = string.Format("ul. Przykładowa {0}", (counter + 3) * 14);
                    var    description = string.Format("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.");
                    var    email       = string.Format("{0}@mailinator.com", companyName);
                    var    phone       = string.Format("{0}264{1}24{2}{3}", counter + 1, counter, counter, counter + 1);

                    Console.WriteLine(companyName);

                    var company = companyCreator.Create(companyName, street, city, postalCode, email, phone, url, description);

                    var offers = c.Descendants("offer").ToList();
                    foreach (var o in offers)
                    {
                        var       offerName = o.Attribute("name").Value;
                        var       trade     = o.Attribute("trade").Value;
                        OfferType type      = null;

                        if (o.Attribute("type").Value == "0")
                        {
                            type = offerTypesProvider.GetAllOfferTypes().Single(n => n.Name.ToLower() == "praktyka");
                        }
                        else
                        {
                            type = offerTypesProvider.GetAllOfferTypes().Single(n => n.Name.ToLower() == "staż");
                        }

                        offerCreator.Create(offerName, description, trade, company, type);
                    }
                }
            }
        }