Beispiel #1
0
 public ProjectController(ProjectManager projectManager, ProjectMetadataManager projectMetadataManager,
                          ProjectInfoManager projectInfoManager, ForumSiteManager forumSiteManager, PermissionManager permissionManager,
                          ProjectGroupManager projectGroupManager, AuthorizationManager authorizationManager)
 {
     m_projectManager         = projectManager;
     m_projectMetadataManager = projectMetadataManager;
     m_projectInfoManager     = projectInfoManager;
     m_forumSiteManager       = forumSiteManager;
     m_permissionManager      = permissionManager;
     m_projectGroupManager    = projectGroupManager;
     m_authorizationManager   = authorizationManager;
 }
        public ActionResult SaveProjectGroupMembers()
        {
            ProjectGroupManager projectGroupManager = new ProjectGroupManager(Cache, UserContext, GeminiContext);

            int groupId = Request["PGPICKER-GROUP"].ToInt();

            int?projectId = Request["PGPICKER-PROJECT"].ToInt();

            if (projectId == 0)
            {
                projectId = null;
            }

            var group = Cache.ProjectGroups.Get(groupId);

            var members = Request["PGPICKER__" + groupId].SplitEntries(',', 0);

            var newMembers = members.Except(group.MembersForProject(projectId).Select(gg => gg.UserId));

            var removedMembers = group.MembersForProject(projectId).Select(gg => gg.UserId).Except(members);

            foreach (var newMember in newMembers)
            {
                projectGroupManager.CreateMembership(new ProjectGroupMembership()
                {
                    ProjectGroupId = group.Id, UserId = newMember, ProjectId = projectId
                });
            }

            var excludedUsers = GetExcludedUsers(projectId.GetValueOrDefault());

            foreach (var removedMember in removedMembers)
            {
                // Check if the removed member is not part of the exclude settings and then remove!
                if (!excludedUsers.Contains(removedMember))
                {
                    projectGroupManager.DeleteMembership(group.Id, removedMember, projectId);
                }
            }

            if (groupId == Countersoft.Gemini.Commons.Constants.GlobalGroupAdministrators)
            {
                projectGroupManager.CreateMembership(new ProjectGroupMembership()
                {
                    ProjectGroupId = Countersoft.Gemini.Commons.Constants.GlobalGroupAdministrators, UserId = Countersoft.Gemini.Commons.Constants.SystemAccountUserId, ProjectId = null
                });
            }

            group = GeminiContext.ProjectGroups.Get(groupId);
            var groupMembers = new List <ProjectGroupMembership>(group.Members);

            groupMembers.RemoveAll(m => m.UserId == Countersoft.Gemini.Commons.Constants.SystemAccountUserId);
            group.Members = groupMembers;

            int myProjects = group.Members.FindAll(m => m.ProjectId == projectId.Value && !excludedUsers.Contains(m.UserId)).Count();

            return(JsonSuccess(new
            {
                Html = GetSummary(myProjects)
            }));
        }
 public ProjectGroupController()
 {
     ProjectGroupManager = new ProjectGroupManager();
     SupervisorManager   = new SupervisorManager();
     StudentManager      = new StudentManager();
 }
 public ReportController()
 {
     ProjectListManager  = new ProjectListManager();
     ProjectGroupManager = new ProjectGroupManager();
     ReportManager       = new ReportManager();
 }