public ActionResult AssignProject(int id) { ProjectUsersViewModel ProjectUsersVM = new ProjectUsersViewModel(); ProjectUsersVM.Project = _context.Projects.Find(id); ProjectUsersVM.Users = _context.Users.Where(u => u.RoleId == 3).ToList(); ProjectUsersVM.Request = new Request(); return(View(ProjectUsersVM)); }
public ActionResult AddMember(int ProjectId) { Project project = _context.Projects.Find(ProjectId); List <User> users = _context.Users.Where(u => u.RoleId == 4 || u.RoleId == 5).ToList(); ProjectUsersViewModel ProjectUsersVM = new ProjectUsersViewModel(); ProjectUsersVM.Project = project; ProjectUsersVM.Users = users; return(View(ProjectUsersVM)); }
public List <ProjectUsersViewModel> GetAllUsers() { var users = userManager.Users; List <ProjectUsersViewModel> projectUsersViewModel = new List <ProjectUsersViewModel>(); foreach (var user in users) { var userModel = new ProjectUsersViewModel { UserId = user.Id, Username = user.FirstName + " " + user.LastName }; projectUsersViewModel.Add(userModel); } return(projectUsersViewModel); }
public ActionResult PMAssignations(int id) { // get a list of the projects in the DB var project = db.Projects.Find(id); // instantiate the view model var model = new ProjectUsersViewModel(); model.AssignProjectManagers = new AssignProjectManagersViewModel(); model.UnassignProjectManagers = new UnassignProjectManagersViewModel(); // model.AssignProjectManagers.ProjectId = project.Id; model.AssignProjectManagers.ProjectName = project.Name; var PMNotOnProject = helper.ListManagersNotOnProject(project.Id); model.AssignProjectManagers.Users = new MultiSelectList(PMNotOnProject.OrderBy(d => d.DisplayName), "Id", "DisplayName", null); // model.UnassignProjectManagers.ProjectId = project.Id; model.UnassignProjectManagers.ProjectName = project.Name; var PMOnProject = helper.ListManagersOnProject(project.Id); model.UnassignProjectManagers.Users = new MultiSelectList(PMOnProject.OrderBy(d => d.DisplayName), "Id", "DisplayName", null); return(View(model)); }
public OperationResult <ProjectSettingsViewModel> GetProjectSettings(string userId, int projectId, int page = 0, string searchFilter = "") { try { bool canUserChangeProject = CanUserChangeProject(userId, projectId); if (!canUserChangeProject) { return(new OperationResult <ProjectSettingsViewModel> { Model = null, Message = GenericServiceResult.AccessDenied }); } Project project = unitOfWork.Projects.Get(projectId); ProjectSettings projectSettings = unitOfWork.ProjectSettings.Get(projectId); List <ProjectUser> projectUsers = unitOfWork.ProjectUser.Get(p => p.ProjectId == projectId).ToList(); List <User> users = (from u in unitOfWork.Users.Query() join r in projectUsers on u.Id equals r.UserId where u.UserName.Contains(searchFilter) select u ).Skip(page * 15).Take(15).ToList(); int rowsCount = projectUsers.Count; List <UserInfo> userInfos = new List <UserInfo>(); foreach (var user in users) { UserProfile profile = unitOfWork.ClientManager.GetProfile(user.Id); int userRole = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.UserId == user.Id && p.ProjectId == projectId).Role; bool isUserAdministrator = (ProjectRoles)userRole == ProjectRoles.Administrator; bool canYouDeleteUser = isUserAdministrator || userId == user.Id; UserInfo userInfo = new UserInfo { Id = user.Id, Email = user.Email, Icon = profile.Icon, Name = profile.Name, CanYouDeleteUser = !canYouDeleteUser }; userInfos.Add(userInfo); } ProjectUsersViewModel projectUsersModel = new ProjectUsersViewModel { ProjectUsers = userInfos, CurrentPage = page, PageSize = 15, RowsCount = rowsCount }; projectUsersModel.GetPages(); bool canUserDeleteProject = CanUserDeleteProject(userId, projectId); ProjectSettingsViewModel model = new ProjectSettingsViewModel { Id = projectId, Title = project.Title, About = project.About, AccessToChangeProject = (ProjectSettingsRole)projectSettings.AccessToChangeProject, AccessToCreateBoard = (BoardSettingsRole)projectSettings.AccessToCreateBoard, AccessToDeleteBoard = (BoardSettingsRole)projectSettings.AccessToDeleteBoard, ProjectUsersViewModel = projectUsersModel, CanUserDeleteProject = canUserDeleteProject }; return(new OperationResult <ProjectSettingsViewModel> { Model = model, Message = GenericServiceResult.Success }); } catch { return(new OperationResult <ProjectSettingsViewModel> { Model = null, Message = GenericServiceResult.Error }); } }