public async Task <IActionResult> GetResultTeamMember(int sprintId, int teamMemberId = 1) { var completedSprint = await _manageSprintsService.GetSprintAsync(sprintId, true); var members = await GetAllTeamMembersAsync(completedSprint.TeamId); var currentMember = members.FirstOrDefault(member => member.Id == teamMemberId); if (completedSprint == null || currentMember == null || completedSprint == null) { return(RedirectToAction("GetResultError", new { errorMessage = _localizer["CouldntGetData"] })); } if (completedSprint.Status != 2) { return(RedirectToAction("GetResultError", new { errorMessage = _localizer["StatusIsNotComplete"] })); } var tasksAllParams = await _manageTasksService.GetTasksAllParamsForMember(teamMemberId, sprintId); var teamMemberTotalSp = tasksAllParams.TeamMemberTotalSp; var storyPointsInDay = await _manageMemberWorkingDaysService.GetStoryPointsInDayForMember(sprintId, teamMemberId, teamMemberTotalSp); tasksAllParams.AddStoryPointsInDay(storyPointsInDay); var resultsTasksForMemberViewModel = ResultsTasksForMemberViewModel.Create(completedSprint, currentMember, tasksAllParams); return(View(resultsTasksForMemberViewModel)); }
public async Task <IActionResult> GetResultTeamMember(int sprintId, int teamMemberId = 1) { var completedSprint = await _manageSprintsService.GetSprintAsync(sprintId, true); var members = await GetAllTeamMembersAsync(completedSprint.TeamId); var currentMember = members.FirstOrDefault(member => member.Id == teamMemberId); if (completedSprint == null || currentMember == null || completedSprint == null) { return(RedirectToAction("GetResultError", new { errorMessage = _localizer["CouldntGetData"] })); } if (completedSprint.Status != 2) { return(RedirectToAction("GetResultError", new { errorMessage = _localizer["StatusIsNotComplete"] })); } var allMemberTasks = completedSprint.Tasks.Where(t => t.MemberId == teamMemberId).ToList(); var allSprintTasks = completedSprint.Tasks.ToList(); if (allMemberTasks == null) { return(RedirectToAction("GetResultError", new { errorMessage = _localizer["TasksNotExists"] })); } Dictionary <string, int> tasksSp = GetTasksStoryPoints(allMemberTasks); int spCompletedTasks = tasksSp.GetValueOrDefault("spCompletedTasks"); int spUnCompletedTasks = tasksSp.GetValueOrDefault("spUnCompletedTasks"); int totalStoryPoints = 0; int quantityСompletedTasks = allMemberTasks.Count(t => t.Completed == true); int quantityUnСompletedTasks = allMemberTasks.Count(t => t.Completed == false); allMemberTasks.ForEach(t => totalStoryPoints += t.StoryPoints); var allWorkingDaysForSprint = await _manageMemberWorkingDaysService.GetAllWorkingDaysForSprintAsync(sprintId); var memberWorkingDays = allWorkingDaysForSprint.Where(i => i.MemberId == teamMemberId).FirstOrDefault(); if (memberWorkingDays == null) { RedirectToAction("GetResultError", new { errorMessage = "Can't get count of working days in the current team member" }); } var teamMemberTotalSp = spCompletedTasks + spUnCompletedTasks; var storyPointsInDay = Convert.ToDouble(teamMemberTotalSp) / Convert.ToDouble(memberWorkingDays.WorkingDays); var resultsTasksForMemberViewModel = new ResultsTasksForMemberViewModel() { TeamMemberId = currentMember.Id, TeamId = completedSprint.TeamId, CompletedSprintId = completedSprint.Id, TeamMemberEmail = currentMember.Member.Email, SprintName = completedSprint.Name, Tasks = new List <TaskViewModel>(), TeamMembers = new List <TeamMemberViewModel>(), TotalStoryPoints = totalStoryPoints, QuantityСompletedTasks = quantityСompletedTasks, QuantityUnСompletedTasks = quantityUnСompletedTasks, SpСompletedTasks = spCompletedTasks, SpUnСompletedTasks = spUnCompletedTasks, StoryPointsInDay = storyPointsInDay }; allMemberTasks.ForEach(t => resultsTasksForMemberViewModel.Tasks.Add(new TaskViewModel() { TeamMember = new TeamMemberViewModel() { Member = t.TeamMember.Member }, Name = t.Name, StoryPoints = t.StoryPoints, Id = t.Id, Link = t.Link, Completed = t.Completed } )); allSprintTasks.ForEach(t => resultsTasksForMemberViewModel.TeamMembers.Add(new TeamMemberViewModel() { Id = t.TeamMember.Id, TeamId = t.TeamMember.TeamId.GetValueOrDefault(), MemberId = t.TeamMember.Id.ToString(), Member = t.TeamMember.Member } )); return(View(resultsTasksForMemberViewModel)); }