Beispiel #1
0
        public StaffController()
        {
            staffList     = SchoolDBAAdapter.FetchAllStaff();//load all staffs to local
            viewableStaff = new ObservableCollection <Staff>(staffList);

            foreach (Staff s in staffList)
            {
                s.eventList = SchoolDBAAdapter.FetchEvent(s.ID);
                s.classList = SchoolDBAAdapter.FetchUnitByID(s.ID);
                s.AvilInfo  = Availability(s.ID);
            }
        }
Beispiel #2
0
        public string Availability(int ID)
        {
            List <UnitClass> classlist = SchoolDBAAdapter.FetchClassByID(ID);
            List <Event>     eventlist = SchoolDBAAdapter.FetchEvent(ID);
            string           result;

            DateTime now = DateTime.Now;

            dt = DateTime.Today.DayOfWeek.ToString();
            TimeSpan time = now.TimeOfDay;

            var cls = from UnitClass uc in classlist
                      where uc.Day == dt && uc.Start <= time && uc.End >= time
                      select uc;
            int classnum           = cls.ToList().Count();
            List <UnitClass> teach = cls.ToList <UnitClass>();
            var evt = from Event et in eventlist
                      where et.Day == dt && et.Start <= time && et.End >= time
                      select et;
            int eventnum = evt.ToList().Count();

            if (eventnum > 0)
            {
                result = "Consulting";
            }
            else if (classnum > 0)
            {
                result = "Teaching" + " (" + teach[0].Unit_Code + "," + teach[0].Room + ")";
            }
            else
            {
                result = "Free";
            }
            //Availability status = ParseEnum<Availability>(result);
            return(result);
        }