Пример #1
0
        public ActionResult Files(string courseTC)
        {
            var course = CourseService.GetByPK(courseTC);
            var info   = GetUserCourseInfo(courseTC) ?? new UserCourseInfo {
                Course_TC = courseTC,
            };

            var model = new FileListVM {
                Course = course,
                Files  = course.CourseFiles.Select(cf => cf.UserFile)
                         .Where(cf => cf.UserID == User.UserID).ToList()
            };

            model.UserFiles = FileVMService.GetUserFiles(courseTC);
            return(BaseView(new PagePart(ViewNames.Files, model),
                            new PagePart(new UserCourseInfoView().Init(info, Url))));
        }
Пример #2
0
        public GroupVM GetGroup(decimal groupID)
        {
            var group = GroupService.GetByPK(groupID);

            if (group == null)
            {
                return(null);
            }
            var            user           = AuthService.CurrentUser;
            var            sglList        = new List <StudentInGroupLecture>();
            StudentInGroup studentInGroup = null;

            if (user.GetOrDefault(x => x.IsStudent))
            {
                studentInGroup = GetSig(groupID);
                if (studentInGroup != null)
                {
                    sglList = GetSqlList(studentInGroup);
                }
            }



            var lectureOffset = 0;
            var lecturesGroup = group.IsOpenLearning
                        ? GroupService.GetByPK(group.MegaGroup_ID.Value) : group;
            var lectures   = lecturesGroup.Lectures.OrderBy(l => l.LectureDateBeg).ToList();
            var lecturesVM = lectures.Select(l => {
                var lectureHours = GetLectureHours(l);
                lectureOffset   += lectureHours;
                return(new GroupVM.LectureVM
                {
                    Lecture = l,
                    Contents = GetContent(group.Course, lectureOffset - lectureHours,
                                          lectureHours),
                    StudentLecture = sglList.FirstOrDefault(
                        sgl => sgl.Lecture_ID == l.Lecture_ID)
                });
            }).ToList();

            var groupFiles     = @group.GroupFiles.Select(g => g.UserFile).ToList();
            var groupUserFiles = groupFiles.Select(x => x.UserFileID);
            var fileList       = new FileListVM {
                Group     = group,
                Files     = groupFiles,
                UserFiles = FileVMService.GetUserFiles(null)
                            .Where(x => !groupUserFiles.Contains(x.UserFileID)).ToList()
            };
            var tests             = SiteObjectService.GetByRelationObject <Test>(group.Course).ToList();
            var testAfterComplete = new List <Test>();

            if (studentInGroup != null)
            {
                var isBegin = group.DateBeg.GetValueOrDefault() + group.TimeBeg.GetValueOrDefault().TimeOfDay <= DateTime.Now;
                if (group.Course_TC == CourseTC.DpCons && isBegin)
                {
                    testAfterComplete = TestService.CourseTests()
                                        .GetValueOrDefault(studentInGroup.Track_TC) ?? new List <Test>();
                }
                else
                {
                    testAfterComplete = TestService.CourseTests()
                                        .GetValueOrDefault(@group.Course_TC) ?? new List <Test>();
                }
            }
            var trainerUserId = group.Teacher.GetOrDefault(x =>
                                                           x.User.GetOrDefault(y => y.UserID));
            var trainerCourseInfo = UserCourseInfoService.FirstOrDefault(x =>
                                                                         x.UserID == trainerUserId && x.Course_TC == group.Course_TC)
                                    .GetOrDefault(x => x.Description);
            var sigId        = studentInGroup.GetOrDefault(x => x.StudentInGroup_ID);
            var IsCertExists = CertificateService.GetAll(x =>
                                                         x.StudentInGroup_ID == sigId).Any();
            var isUnlimit      = studentInGroup.GetOrDefault(x => x.IsUnlimit);
            var r              = GetHideVideo(studentInGroup, sglList, group);
            var hideVideo      = r.Item1;
            var hideForUnlimit = r.Item2;
            var canAccessVideo = r.Item3;


            return(new GroupVM
            {
                Group = group,
                TrainerCourseInfo = trainerCourseInfo,
                Lectures = lecturesVM,
                LastMessages = GetLastMessages(groupID),
                FileList = fileList,
                CanAccessVideo = canAccessVideo,
                Tests = tests,
                TestsAfterComplete = testAfterComplete,
                StudentInGroup = studentInGroup,
                IsCertExists = IsCertExists,
                User = user,
                HideForUnlimit = hideForUnlimit,
                HideVideo = hideVideo,
                IsUnlimit = isUnlimit,
                Progress = GetProgress(lectures, group, studentInGroup)
            });
        }