public ActionResult GrantUserAccessToProject(ProjectUserAccessViewModel model) { if (model.UserId != null && !model.UserId.Equals("")) { UserAccessModel userAccessModel = new UserAccessModel() { Id = model.Id, ProjectId = model.ProjectId, UserId = model.UserId }; _dataManager.AddUserAccessToProject(userAccessModel); _dataManager.SaveChanges(); } return(RedirectToAction("EditProjectAccess", "Projects", new { Id = model.ProjectId })); }
public ActionResult AddUserToProject(int projectId) { var currentProject = _dataManager.ProjectList.SingleOrDefault(project => project.Id == projectId); if (currentProject == null) { return(HttpNotFound()); } var userAccess = _dataManager.GetUserAccessOnProject(projectId); List <UserSelectViewModel> selectableUsers = new List <UserSelectViewModel> { new UserSelectViewModel() { Id = "", UserName = "******" } }; _dataManager.UserList.ForEach(user => { if (userAccess.Find(access => access.UserId.Equals(user.Id)) == null) { selectableUsers.Add(Mapper.Map <UserSelectViewModel>(user)); } }); ProjectUserAccessViewModel model = new ProjectUserAccessViewModel() { Id = 0, ProjectId = projectId, UserList = selectableUsers }; return(PartialView("AddUserToProject", model)); }