コード例 #1
0
        public ActionResult CourseConnections(CourseConnectViewModel newData)
        {
            #region Security
            if (EnforceSecurity(SecurityState.ADMIN) != null)
            {
                return(EnforceSecurity(SecurityState.ADMIN));
            }
            #endregion

            List <PersonViewModel> persons = newData.UnConnectedUsers;

            foreach (PersonViewModel item in persons)
            {
                if (item.isChecked)
                {
                    if (item.Role == "Student")
                    {
                        PersonService.ConnectStudents(item.ID, (newData.CurrentCourse.ID));
                    }
                    else if (item.Role == "Teacher")
                    {
                        PersonService.ConnectTeachers(item.ID, (newData.CurrentCourse.ID));
                    }
                }
            }

            return(RedirectToAction("CourseConnections", new { courseID = newData.CurrentCourse.ID }));
        }
コード例 #2
0
        /// <summary>
        /// A function that displays the view used to connect users to courses
        /// as teachers and students
        /// </summary>
        public ActionResult CourseConnections(int?courseID)
        {
            #region Security
            if (EnforceSecurity(SecurityState.ADMIN) != null)
            {
                return(EnforceSecurity(SecurityState.ADMIN));
            }
            #endregion

            if (courseID.HasValue)
            {
                int ID = courseID.Value;
                //var PersonsToAppend = PersonService.GetAllPersons();
                var PersonsToAppend              = PersonService.GetAllNotConnected(ID);
                var courseToAppend               = CourseService.GetCourseByID(ID).toCourse();
                var teachersToAppend             = PersonService.GetAllTeachers(ID);
                var studentsToAppend             = PersonService.GetAllStudents(ID);
                CourseConnectViewModel viewModel = new CourseConnectViewModel
                {
                    UnConnectedUsers = PersonsToAppend,
                    CurrentCourse    = courseToAppend,
                    Teachers         = teachersToAppend,
                    Students         = studentsToAppend
                };
                return(View(viewModel));
            }
            return(RedirectToAction("Index"));
        }