Beispiel #1
0
        public async Task <IActionResult> ManageProjectsAsync()
        {
            var allProjects = _bug.GetAllProjects();
            var currentUser = await _userManager.FindByNameAsync(User.Identity.Name)
                              .ConfigureAwait(false);

            var allUsers = await _userBug.GetAllTeamMembersAsync(currentUser)
                           .ConfigureAwait(false);

            var userProjects = await _userBug.GetGetAllUserProjectsByUserAsync(currentUser)
                               .ConfigureAwait(false);

            var allTeams = await _userBug.GetAllTeamsByUser(currentUser)
                           .ConfigureAwait(false);

            var assignedListingModel = userProjects
                                       .Select(result => new AssignedProjectListingModel
            {
                FullName     = result.User.FirstName + " " + result.User.LastName,
                Username     = result.User.UserName,
                EmailAddress = result.User.Email,
                Project      = result.Project.Name
            });
            var listingModel = allProjects
                               .Select(result => new ProjectListingModel
            {
                Project = result.Name,
                Manager = (_userBug.GetManagerAsync(result.Owner).Result)?.UserName,
                Team    = result.Owner?.Name,
                Email   = (_userBug.GetManagerAsync(result.Owner).Result)?.Email
            });
            // list anyone that is not just a submitter
            var model = new ProjectIndexModel
            {
                UserProjects = assignedListingModel,
                TeamProjects = listingModel,
                Projects     = (await _userBug.GetAllProjectByUserAsync(currentUser)
                                .ConfigureAwait(false)).Select(proj => proj.Name),
                Users = allUsers.Select(user => user.UserName),
                Teams = allTeams.Select(team => team.Name)
            };

            return(View(model));
        }
        public async Task <IActionResult> IndexAsync()
        {
            SubmissionOptionsModel options = null;
            var currentUser = await _userManager.FindByNameAsync(User.Identity.Name)
                              .ConfigureAwait(false);

            if (User.IsInRole("Admin"))
            {
                options = new SubmissionOptionsModel()
                {
                    ProjectOptions = _bug.GetAllProjects().Select(proj => proj.Name),
                    TeamOptions    = _bug.GetAllTeams().Select(team => team.Name),
                    UrgencyOptions = _bug.GetAllUrgencies().Select(urgency => urgency.Level)
                };
            }
            else if (User.IsInRole("Manager"))
            {
                options = new SubmissionOptionsModel()
                {
                    ProjectOptions = (await _userBug.GetAllProjectByUserAsync(currentUser)
                                      .ConfigureAwait(false))
                                     .Select(proj => proj.Name),
                    UserProjectOptions = _userBug.GetAllUserProjectsByUser(currentUser)
                                         .Select(result => new UserProjectModel
                    {
                        Username = result.User.UserName,
                        Project  = result.Project.Name
                    }),
                    UrgencyOptions = _bug.GetAllUrgencies().Select(urgency => urgency.Level)
                };
            }

            var model = new SubmissionIndexModel()
            {
                Options = options
            };

            return(View(model));
        }