public async Task <IActionResult> ProjectDetails(int projectId) { var project = new Project(); if (projectId > 0) { project = _projectRepository.GetProject(projectId); Global.ProjectId = projectId; } else { project = _projectRepository.GetProject(Global.ProjectId); } Global.Project = project; var userId = userManager.GetUserId(User); var currentUser = await userManager.FindByIdAsync(userId); var claims = await userManager.GetClaimsAsync(currentUser); Global.globalCurrentUserClaims = claims.ToList(); var IsUserLevel = ClaimsLevel.IsUser(claims.ToList(), projectId); //if (IsUserLevel == false) //{ // return RedirectToAction("AccessDenied", "Account"); //} var projectIssues = _issueRepository.GetAllProjectIssues(projectId); var projectHistory = _projectRepository.GetAllProjectHistories(projectId); if (project != null) { Console.WriteLine(project.ProjectId); } var viewModel = new ProjectDetailsViewModel { Project = project, projectHistories = projectHistory, ProjectId = projectId, ProjectIssues = projectIssues }; return(View(viewModel)); }
public async Task <IActionResult> AddIssue(int projectId) { Global.ProjectId = projectId; var initial = new Issue { AssociatedProject = projectId, DueDate = DateTime.Today }; var project = _projectRepository.GetProject(projectId); Global.Project = project; var userId = userManager.GetUserId(User); var currentUser = await userManager.FindByIdAsync(userId); var userClaims = await userManager.GetClaimsAsync(currentUser); Global.globalCurrentUserClaims = userClaims.ToList(); var IsUserLevel = ClaimsLevel.IsUser(userClaims.ToList(), projectId); if (IsUserLevel == false) { return(RedirectToAction("AccessDenied", "Account")); } var users = new List <IdentityUser>(); var projectUsers = new List <String>(); projectUsers.Add(project.OwnerId); if (project.UsersAssigned != null) { projectUsers.AddRange(project.UsersAssigned.Split(" ").ToList()); } Console.WriteLine(projectUsers[0]); foreach (var uId in projectUsers) { var user = await userManager.FindByIdAsync(uId); Console.WriteLine($"user is {user}"); if (user != null && !users.Contains(user)) { users.Add(user); } } var viewModel = new AddNewIssueViewModel { ProjectId = projectId, ProjectUsers = users, NewIssue = initial }; foreach (var user in users) { Console.WriteLine("USEr EMAIL"); Console.WriteLine(user.Email); } return(View(viewModel)); }
public async Task <IActionResult> IssueDetails(int issueId) { var issue = _issueRepository.GetIssue(issueId); Global.ProjectId = issue.AssociatedProject; var project = _projectRepository.GetProject(issue.AssociatedProject); Global.Project = project; var userId = userManager.GetUserId(User); var currentUser = await userManager.FindByIdAsync(userId); var userClaims = await userManager.GetClaimsAsync(currentUser); Global.globalCurrentUserClaims = userClaims.ToList(); var IsUserLevel = ClaimsLevel.IsUser(userClaims.ToList(), issue.AssociatedProject); if (IsUserLevel == false) { return(RedirectToAction("AccessDenied", "Account")); } var screenshots = _issueRepository.ScreenShots(issueId); var projectName = project.ProjectName; var comments = _issueRepository.Comments(issueId); var issueHistory = _issueRepository.GetIssueHistories(issueId); issue.Comments = comments; var users = new List <IdentityUser>(); var projectUsers = new List <string>(); projectUsers.Add(project.OwnerId); if (project.UsersAssigned != null) { projectUsers.AddRange(project.UsersAssigned.Split(" ").ToList()); } foreach (var uId in projectUsers) { var user = await userManager.FindByIdAsync(uId); if (user != null && !users.Contains(user)) { users.Add(user); } } var viewModel = new IssueDetailsViewModel { Issue = issue, IssueHistories = issueHistory, ProjectId = issue.AssociatedProject, CurrentUserName = User.Identity.Name, ProjectName = project.ProjectName, ProjectUsers = users, Source = screenshots, Updated = 0 }; return(View(viewModel)); }