public async Task <IActionResult> AddTask(string id) { ViewData["TaskStatuses"] = _storyService.GetAllTaskStatus(); var model = new BoardAddTaskViewModel { StoryId = id, Users = new List <ProjectUserDetailViewModel>() }; var users = _userManager.Users.Select(user => new UserDetailViewModel { Id = user.Id, FirstName = user.FirstName, LastName = user.LastName, Username = user.UserName, Email = user.Email, PhoneNumber = user.PhoneNumber, ImageUrl = user.ImageUrl }); var roles = _roleManager.Roles .Where(x => x.Name != "Admin") .OrderBy(x => x.Name) .Select(r => new ApplicationRoleDetailViewModel { Id = r.Id, RoleName = r.Name, Description = r.Description }); var story = await _storyService.GetByIdAsync(int.Parse(id)); var sprint = await _sprintService.GetByIdAsync(story.SprintId); // var userRoles = _projectService.GetProjectUserRoles(sprint.ProjectId.ToString()); foreach (var userRole in userRoles) { var user = await users.FirstOrDefaultAsync(x => x.Id == userRole.UserId); var role = await roles.FirstOrDefaultAsync(x => x.Id == userRole.RoleId); var projectUser = new ProjectUserDetailViewModel { ProjectId = id, UserId = userRole.UserId, RoleId = userRole.RoleId, FirstName = user.FirstName, LastName = user.LastName, ImageUrl = user.ImageUrl, UserRoleName = role.RoleName }; model.Users.Add(projectUser); } return(View(model)); }