Beispiel #1
0
        public static void RandomDB(ClassDAO classDAO, TeacherDAO teacherDAO, LessonDAO lessonDAO, PupilDAO pupilDAO, JunctionDAO junctionDAO)
        {
            RandomGen random = new RandomGen();

            string[] lessonNames = random.getLessons();
            for (int i = 0; i < lessonNames.Length; i++)
            {
                Teacher t = new Teacher(-1, random.getRandomName(), random.getRandomSurname());
                teacherDAO.Create(t);
            }

            List <Teacher> teachers = teacherDAO.GetList();

            for (int i = 0; i < teachers.Count; i++)
            {
                Lesson l = new Lesson(-1, lessonNames[i], random.getRandomDouble(10), teachers.ElementAt(i).Id);
                lessonDAO.Create(l);
            }
            List <Lesson> lessons       = lessonDAO.GetList();
            List <long>   lessonIndexes = new List <long>();

            foreach (Lesson t in lessons)
            {
                lessonIndexes.Add(t.Id);
            }

            string[] classNames = random.getClassnames();
            for (int i = 0; i < classNames.Length; i++)
            {
                Class c = new Class(-1, classNames[i], random.getRandomSpec(), random.getRandomCreationDate());
                classDAO.Create(c);
            }
            List <Class> classes = classDAO.GetList();

            foreach (Class c in classes)
            {
                int pupilAmount = random.getRandomInt(20, 31);
                for (int i = 0; i < pupilAmount; i++)
                {
                    Pupil p = new Pupil(-1, random.getRandomName(), random.getRandomSurname(), c.Id,
                                        random.getRandomBirthDate(), random.getRandomBoolean());
                    pupilDAO.Create(p);
                }

                for (int i = 0; i < 7; i++)
                {
                    Junction j = new Junction(-1, c.Id, random.getRandomIndex(lessonIndexes));
                    junctionDAO.Create(j);
                }
            }
        }
Beispiel #2
0
        public void RandomDB(HallDAO hallDAO, MovieDAO movieDAO, TicketDAO ticketDAO, SeanceDAO seanceDAO)
        {
            RandomGen random = new RandomGen();

            for (int i = 0; i < 10; i++)
            {
                Hall h = new Hall(-1, random.getRandomFormat(), random.getRandomNumber(40, 61));
                hallDAO.CreateHall(h);
            }

            List <Hall> halls        = hallDAO.GetHalls();
            List <long> hallsIndexes = new List <long>();

            foreach (Hall h in halls)
            {
                hallsIndexes.Add(h.Id);
            }

            for (int i = 0; i < halls.Count; i++)
            {
                int seatsAmount = halls.ElementAt(i).SeatsAmount;
                for (int j = 0; j < seatsAmount; j++)
                {
                    Seat s = new Seat(-1, j + 1, (int)j / 10 + 1, i, random.getRandomBoolean());
                    hallDAO.CreateSeat(s);
                }
            }
            List <Seat> seats        = hallDAO.GetSeats();
            List <long> seatsIndexes = new List <long>();

            foreach (Seat s in seats)
            {
                seatsIndexes.Add(s.Id);
            }

            string[] movieTitles = random.getMovies();
            for (int i = 0; i < 20; i++)
            {
                Movie m = new Movie(-1, movieTitles[i], random.getRandomCountry(), random.getRandomPastDate(), random.getRandomNumber(0, 22));
                movieDAO.Create(m);
            }
            List <Movie> movies        = movieDAO.GetList();
            List <long>  moviesIndexes = new List <long>();

            foreach (Movie m in movies)
            {
                moviesIndexes.Add(m.Id);
            }

            for (int i = 0; i < 20; i++)
            {
                Seance s = new Seance(-1, random.getRandomNumber(10, 101), random.getRandomFutureDate(),
                                      random.getRandomIndex(moviesIndexes), random.getRandomIndex(hallsIndexes));
                seanceDAO.Create(s);
            }
            List <Seance> seances = seanceDAO.GetList();

            foreach (Seance s in seances)
            {
                Ticket t = new Ticket(-1, random.getRandomPastDate(), s.Id, random.getRandomIndex(seatsIndexes));
                ticketDAO.Create(t);
            }
        }