public ScheduleController()
 {
     db = new ZergRushEntities();
     semester = db.Current_Semester.First().semester_id.ToString();
 }
Example #2
0
        public static MvcHtmlString GetClassStatus(this HtmlHelper helper, int class_id, string semester_id, int class_capacity, int waitlist_capacity, string image_path)
        {
            ZergRushEntities courseDB = new ZergRushEntities();
            string format = "<img src=\"{0}\" class=\"class_status\">";
            int class_enrollment = courseDB.GetClassEnrollment(class_id, semester_id).FirstOrDefault() ?? 0;
            if (class_enrollment < class_capacity)
                return MvcHtmlString.Create(string.Format(format, image_path + "/open.png") + " (" + (class_capacity - class_enrollment) + " seats)");

            int waitlist_enrollment = courseDB.GetClassWaitlist(class_id, semester_id).FirstOrDefault() ?? 0;
            if (waitlist_enrollment < waitlist_capacity)
                return MvcHtmlString.Create(string.Format(format, image_path + "/warning.png"));

            return MvcHtmlString.Create(string.Format(format, image_path + "/closed.png"));
        }