private Block GetBlockFromReader(SqlDataReader rdr)
        {
            int id = rdr.GetInt32(0);
            StudentAccessLayer    SAL        = new StudentAccessLayer(_db);
            Student               student    = SAL.GetStudentById(rdr.GetInt32(1));
            InstrumentAccessLayer IAL        = new InstrumentAccessLayer(_db);
            Instrument            instrument = IAL.GetInstrumentById(rdr.GetInt32(2));
            TutorAccessLayer      TAL        = new TutorAccessLayer(_db);
            Tutor             tutor          = TAL.GetTutorByID(rdr.GetInt32(3));
            RoomAccessLayer   RAL            = new RoomAccessLayer(_db);
            Room              room           = RAL.GetRoomByID(rdr.GetInt32(4));
            PeriodAccessLayer PAL            = new PeriodAccessLayer(_db);
            Period            period         = PAL.GetPeriodById(rdr.GetInt32(5));
            TermAccessLayer   TeAL           = new TermAccessLayer(_db);
            Term              term           = TeAL.GetTermById(rdr.GetInt32(6));
            DayOfWeek         day            = (DayOfWeek)rdr.GetInt32(7);

            return(new Block(id, student, tutor, instrument, room, period, term, day));
        }
        public List <Period> GetFreePeriods(Instrument instrument, Term term, DayOfWeek day)
        {
            TutorAccessLayer TAL = new TutorAccessLayer(Session.Database);
            List <Tutor>     tutorsForInstrument = TAL.GetTutorsByInstrument(instrument);
            List <Period>    allPeriods          = GetAllPeriods();

            for (int i = 0; i < allPeriods.Count; i++)
            {
                bool periodAvailable = false;
                foreach (Tutor t in tutorsForInstrument)
                {
                    if (!TAL.IsTutorBusyPeriod(t, term, day, allPeriods[i]))
                    {
                        periodAvailable = true;
                    }
                }
                if (!periodAvailable)
                {
                    allPeriods.RemoveAt(i);
                    i--;
                }
            }
            return(allPeriods);
        }