Пример #1
0
        public ActionResult ManageProjectUsers(List <int> projects, string projectManagerId, List <string> developers, List <string> submitters, string demoProjectManagerId, List <string> demoDevelopers, List <string> demoSubmitters)
        {
            // remove users from selected projects
            if (projects != null && !userRolesHelper.IsDemoUser(User.Identity.GetUserId()))
            {
                foreach (var projectId in projects)
                {
                    // remove from this project
                    foreach (var user in projectsHelper.UsersOnProject(projectId).ToList())
                    {
                        projectsHelper.RemoveUserFromProject(user.Id, projectId);
                    }

                    // add a PM back to projects if possible
                    if (!string.IsNullOrEmpty(projectManagerId))
                    {
                        projectsHelper.AddPMToProject(projectManagerId, projectId);
                    }
                    if (developers != null)
                    {
                        foreach (var developerId in developers)
                        {
                            projectsHelper.AddUserToProject(developerId, projectId);
                        }
                    }
                    if (submitters != null)
                    {
                        foreach (var submitterId in submitters)
                        {
                            projectsHelper.AddUserToProject(submitterId, projectId);
                        }
                    }

                    // demo users
                    if (!string.IsNullOrEmpty(demoProjectManagerId))
                    {
                        projectsHelper.AddUserToProject(demoProjectManagerId, projectId);
                    }
                    if (demoDevelopers != null)
                    {
                        foreach (var demoDeveloperId in demoDevelopers)
                        {
                            projectsHelper.AddUserToProject(demoDeveloperId, projectId);
                        }
                    }
                    if (demoSubmitters != null)
                    {
                        foreach (var demoSubmitterId in demoSubmitters)
                        {
                            projectsHelper.AddUserToProject(demoSubmitterId, projectId);
                        }
                    }
                }
            }

            return(RedirectToAction("ManageProjectUsers"));
        }
        public ActionResult ManageProjects(List <string> userIds, int project, string projectManager)
        {
            foreach (var user in db.Users)
            {
                projectsHelper.RemoveUserFromProject(user.Id, project);
            }

            foreach (var userId in userIds)
            {
                projectsHelper.AddUserToProject(userId, project);
            }

            projectsHelper.AddPMToProject(projectManager, project);

            return(RedirectToAction("ManageProjects", "Admin"));
        }