public static async Task <Func <Slide, string> > BuildGetGitEditLinkFunc(string userId, Course course, ICourseRolesRepo courseRolesRepo, ICoursesRepo coursesRepo) { var courseRole = await courseRolesRepo.GetRole(userId, course.Id); var canEditGit = courseRole <= CourseRoleType.CourseAdmin; if (!canEditGit) { return(s => null); } var publishedCourseVersion = await coursesRepo.GetPublishedCourseVersion(course.Id); if (publishedCourseVersion == null) { return(s => null); } var repoUrl = publishedCourseVersion.RepoUrl; var pathToCourseXml = publishedCourseVersion.PathToCourseXml; if (repoUrl == null || pathToCourseXml == null) { return(s => null); } var courseXmlDirectory = course.CourseXmlDirectory; return(slide => { var pathRelative2CourseXml = slide.Info.SlideFile.FullName.Substring(courseXmlDirectory.FullName.Length + 1); return GitUtils.GetSlideEditLink(repoUrl, pathToCourseXml, pathRelative2CourseXml); }); }
public async Task <List <NotificationType> > GetNotificationTypes(string userId, string courseId) { var notificationTypes = GetAllNotificationTypes(); var courseRole = await courseRolesRepo.GetRole(userId, courseId); notificationTypes = notificationTypes .Where(t => t.GetMinCourseRole() <= courseRole) .OrderByDescending(t => t.GetMinCourseRole()) .ThenBy(t => (int)t) .ToList(); if (!await usersRepo.IsSystemAdministrator(userId)) { notificationTypes = notificationTypes.Where(t => !t.IsForSysAdminsOnly()).ToList(); } return(notificationTypes); }