Ejemplo n.º 1
0
        /// 学生按班级id选择班级.成功返回选课记录id 失败返回0
        public long InsertCourseSelectionById(long userId, long classId)
        {
            try
            {
                //_userService.GetUserByUserId(userId);
                ClassInfo classinfo = GetClassByClassId(classId);

                //找到该班级所属课程下的所有班级
                IList <ClassInfo> classList = ListClassByCourseId(classinfo.Course.Id);
                foreach (ClassInfo c in classList)
                {
                    if (_classDao.GetSelection(userId, c.Id) != 0)//学生已选同课程下其他班级
                    {
                        return(0);
                    }
                }
                CourseSelection coursesele = new CourseSelection();


                UserInfo student = _userService.GetUserByUserId(userId);
                coursesele.Student   = student;
                coursesele.ClassInfo = classinfo;
                return(_classDao.InsertSelection(coursesele));
            }
            catch (UserNotFoundException eu) { throw eu; }
            catch (ClassNotFoundException ec) { throw ec; }
        }
Ejemplo n.º 2
0
        /// 学生按班级id选择班级.成功返回选课记录id 失败返回0
        public async Task <long> InsertCourseSelectionByIdAsync(long userId, long classId)
        {
            //_userService.GetUserByUserIdAsync(userId);
            var classinfo = await GetClassByClassIdAsync(classId);

            //找到该班级所属课程下的所有班级
            var classList = await ListClassByCourseIdAsync(classinfo.Course.Id);

            foreach (var c in classList)
            {
                if (_classDao.GetSelection(userId, c.Id) != 0) //学生已选同课程下其他班级
                {
                    return(0);
                }
            }

            var coursesele = new CourseSelection();


            var student = await _userService.GetUserByUserIdAsync(userId);

            coursesele.Student   = student;
            coursesele.ClassInfo = classinfo;
            return(_classDao.InsertSelection(coursesele));
        }