示例#1
0
        public ActionResult Detail(int SectionID)
        {
            ViewData["Title"] = (proxy.getSection(SectionID).CourseID + " - Section " + SectionID);
            ViewData["Role"]  = Session["role"];
            Section    section    = proxy.getSection(SectionID);
            Course     c          = proxy.getCourse(section.CourseID);
            Instructor instructor = proxy.getInstructor(section.InstructorID);

            Student[] students    = proxy.getSectionStudents(section);
            Student[] waitlist    = proxy.getSectionWaitlist(section);
            int       numStudents = students.Length;

            ViewData["Enrolled"] = numStudents;
            ViewData["Student"]  = this.proxy.getStudent(1);
            User user = (User)Session["user"];

            int waitlistStudents = proxy.getSectionWaitlist(section).Length;

            if (checkPermission("student") || checkPermission("Student"))
            {
                Student student = this.proxy.getStudent(user.ID);
                ViewData["Student"] = student;

                if (numStudents >= section.MaxStudents)
                {
                    ViewData["Enroll"] = "Waitlist";
                }
                else
                {
                    ViewData["Enroll"] = "Enroll";
                }

                foreach (Student s in students)
                {
                    if (s.ID == student.ID)
                    {
                        ViewData["Enroll"] = "Already Enrolled";
                    }
                }
            }



            ViewData["Instructor"] = instructor;
            ViewData["Course"]     = c;
            ViewData["CourseCode"] = c.CourseCode;
            ViewData["CourseName"] = c.Name;
            ViewData["Waitlist"]   = waitlistStudents;
            ViewData["SectionID"]  = section.ID;
            return(View(section));
        }