public IList <Project> GetProjectsAssignedTo(User user) { ProjectRoleRepository projRoleRepo = new ProjectRoleRepository(); return(projRoleRepo.GetAll().Where(p => p.User.Id == user.Id) .Select(c => c.Project).Distinct().ToList()); }
protected virtual void EnsureRoles() { UserRepository repo = new UserRepository(); ProjectRoleRepository projRoleRepo = new ProjectRoleRepository(); User user = repo.GetAll().Where(p => p.Username == _identity.Name).Single(); IList <Role> userRoles = new List <Role>(); IList <ProjectRole> projRoles = projRoleRepo.GetAll().Where(p => p.User.Id == user.Id).ToList(); foreach (ProjectRole projRole in projRoles) { if (!userRoles.Contains(projRole.Role)) { userRoles.Add(projRole.Role); } } _roles = new string[userRoles.Count()]; for (int i = 0; i < _roles.Length; i++) { _roles[i] = userRoles[i].RoleName; } }
public IList <Project> GetProjectsManagedBy(User user) { ProjectRoleRepository projRoleRepo = new ProjectRoleRepository(); RoleRepository roleRepo = new RoleRepository(); Role manager = roleRepo.GetAll().Where(r => r.RoleName == "Project Manager").SingleOrDefault(); return(projRoleRepo.GetAll().Where(p => p.User.Id == user.Id && p.Role.Id == manager.Id).Select(c => c.Project).Distinct().ToList()); }
public IList <User> GetAssignedUsersByProject(Project proj) { ProjectRoleRepository projRoleRepo = new ProjectRoleRepository(); RoleRepository roleRepo = new RoleRepository(); Role projMgr = roleRepo.GetAll().Where(p => p.RoleName == "Project Manager").SingleOrDefault(); return(projRoleRepo.GetAll().Where(p => p.Project.Id == proj.Id && p.Role.Id != projMgr.Id) .Select(p => p.User).Distinct().ToList()); }
public void LeaveProject(Project project, User user) { ProjectRoleRepository projRoleRepo = new ProjectRoleRepository(); var associations = projRoleRepo.GetAll().Where(p => p.User.Id == user.Id && p.Project.Id == project.Id); foreach (var ass in associations) { projRoleRepo.Delete(ass); } }
public List <User> GetUsersByProject(Project proj) { ProjectRoleRepository projRoleRepo = new ProjectRoleRepository(); List <User> userList = new List <User>(); List <ProjectRole> projRoleList = projRoleRepo.GetAll().Where(p => p.Project.Id == proj.Id).ToList(); foreach (ProjectRole projRole in projRoleList) { if (!userList.Contains(projRole.User)) { userList.Add(projRole.User); } } return(userList); }