public async Task <IActionResult> GetAllWorkingDays(int sprintId)
        {
            var sprint = await _manageSprintsService.GetSprintAsync(sprintId, true);

            var workingDays = await _manageMemberWorkingDaysService.GetAllWorkingDaysForSprintAsync(sprintId);

            var team = await _manageSprintsService.GetTeam(sprint.TeamId);

            List <TeamMember> teamMembers = await _manageTeamsMembersService.GetAllTeamMembersAsync(sprint.TeamId, new DisplayOptions { });

            var model = new SprintAndTeamViewModel
            {
                Sprints           = new List <SprintViewModel>(),
                memberWorkingDays = new List <MemberWorkingDaysViewModels>()
            };

            model.sprintId = sprintId;
            model.Team     = new TeamViewModel()
            {
                Id = team.Id, Owner = team.Owner, TeamName = team.TeamName, TeamMembers = new List <TeamMemberViewModel>()
            };
            teamMembers.ForEach(t => model.Team.TeamMembers.Add(new TeamMemberViewModel()
            {
                Id = t.Id, Member = t.Member, MemberId = t.MemberId
            }));
            workingDays.ToList().ForEach(t => model.memberWorkingDays.Add(new MemberWorkingDaysViewModels()
            {
                Id = t.Id, SprintId = sprintId, MemberId = t.MemberId, WorkingDays = t.WorkingDays
            }));
            return(PartialView("_WorkingDaysPartial", model));
        }
        public async Task <IActionResult> GetAllWorkingDays(int sprintId)
        {
            var sprint = await _manageSprintsService.GetSprintAsync(sprintId, true);

            var workingDays = await _manageMemberWorkingDaysService.GetAllWorkingDaysForSprintAsync(sprintId);

            var team = await _manageSprintsService.GetTeam(sprint.TeamId);

            var isOwner = false;

            if (await _accessCheckService.IsOwnerAsync(team.Id))
            {
                isOwner = true;
            }

            var sprintAndTeamViewModel = SprintAndTeamViewModel.Create(sprint, new List <Sprint>(), team, isOwner, workingDays.ToList());

            return(PartialView("_WorkingDaysPartial", sprintAndTeamViewModel));
        }
Exemple #3
0
        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));
        }