예제 #1
0
        public ActionResult Users(DashboardViewModel dashview)
        {
            var allUsers = db.Users.ToList();

            dashview.ApplicationUsers = allUsers;

            dashview.Admins          = allUsers.Where(u => roleHelper.IsUserInRole(u.Id, "Admin")).ToList();
            dashview.ProjectManagers = allUsers.Where(u => roleHelper.IsUserInRole(u.Id, "Project Manager")).ToList();
            dashview.Developers      = allUsers.Where(u => roleHelper.IsUserInRole(u.Id, "Developer")).ToList();
            dashview.Submitters      = allUsers.Where(u => roleHelper.IsUserInRole(u.Id, "Submitter")).ToList();


            return(View(dashview));
        }
예제 #2
0
        public ActionResult ManageProjectLevelUsers(List <string> userIds, int projectId)
        {
            if (userIds != null)
            {
                //var projMembersIds = projHelper.UsersOnProject(projectId).Select(u => u.Id).ToList();

                //foreach(var memberId in projMembersIds)
                //{
                //    projHelper.RemoveUserFromProject(memberId, projectId);
                //}

                foreach (var userId in userIds)
                {
                    if (!projHelper.IsUserOnProject(userId, projectId))
                    {
                        projHelper.AddUserToProject(userId, projectId);
                        if (rolesHelper.IsUserInRole(userId, "ProjectManager"))
                        {
                            var proj = db.Projects.Find(projectId);
                            proj.ProjectManagerId = userId;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        projHelper.RemoveUserFromProject(userId, projectId);
                        if (rolesHelper.IsUserInRole(userId, "ProjectManager"))
                        {
                            var proj = db.Projects.Find(projectId);
                            proj.ProjectManagerId = null;
                            db.SaveChanges();
                        }
                    }
                }
            }

            return(RedirectToAction("ManageProjectLevelUsers", new { id = projectId }));
        }