public IEnumerable <VmTaskBaseGrade> GetGradeReportList(string judgeUserId) { var viewTaskTeamRepository = UnitOfWork.GetRepository <ViewTaskTeamRepository>(); IEnumerable <ViewTaskTeam> taskTeamRepositoryList; if (!string.IsNullOrWhiteSpace(judgeUserId)) { taskTeamRepositoryList = viewTaskTeamRepository.GetTaskTeamByJudge(judgeUserId).ToList(); } else { taskTeamRepositoryList = viewTaskTeamRepository.Select(0, int.MaxValue).ToList(); } var viewTaskRepository = UnitOfWork.GetRepository <ViewTaskRepository>(); var taskGradeList = viewTaskRepository.GetViewTaskByIds(taskTeamRepositoryList.Select(t => t.TaskId).Distinct().ToArray()).ToList(); var blTeamGradeDetail = new BLTeamGradeDetail(); var teamGradeDetailList = blTeamGradeDetail.GetAllTeamGradeDetailByTaskIds(taskTeamRepositoryList.Select(t => t.TaskId).Distinct().ToArray()).ToList(); var taskBaseGradeList = (from task in taskTeamRepositoryList group task by new { task.TaskId, task.TaskName } into g select new VmTaskBaseGrade { TaskId = g.Key.TaskId, TaskName = g.Key.TaskName, GradeList = (from gt in taskGradeList where gt.Id == g.Key.TaskId select new VmGrade { Id = gt.GradeId, Name = gt.Grade }).ToList(), TeamGradeList = (from team in g.ToList() group team by new { team.TeamId, team.TeamName } into tg select new VmTeamGrade { TeamId = tg.Key.TeamId, TeamName = tg.Key.TeamName, }).ToList() }).ToList(); foreach (var taskBaseGrade in taskBaseGradeList) { foreach (var team in taskBaseGrade.TeamGradeList) { team.GradeReportList = new List <VmGradeReport>(); foreach (var grade in taskBaseGrade.GradeList) { team.GradeReportList.Add(new VmGradeReport { GradeId = grade.Id, GradeType = grade.Name, Average = GetAverageTotal(teamGradeDetailList, taskBaseGrade.TaskId, team.TeamId, grade.Id) }); } } } return(taskBaseGradeList); }
public List <VmTaskBaseGrade> GetStudentOtherTeamGradeReportList(string studentUserId, int teamId) { var viewTaskTeamRepository = UnitOfWork.GetRepository <ViewTaskTeamRepository>(); IEnumerable <ViewTaskTeam> taskTeamRepositoryList; var blTeamMember = new BLTeamMember(); var teamMember = blTeamMember.GetTeamMemberByUserIdAndTeamId(studentUserId, teamId); var taskId = teamMember.TaskId.Value; var blUserTask = new BLUserTask(); var judgeUserTaskList = blUserTask.GetUsersByTask(taskId); var bTeam = new BLTeam(); var teamIdList = bTeam.GetTeamIdsByTask(taskId); taskTeamRepositoryList = viewTaskTeamRepository.GetTaskTeamByJudgesAndteamIds(judgeUserTaskList.ToArray(), teamIdList.ToArray()).ToList(); var viewTaskRepository = UnitOfWork.GetRepository <ViewTaskRepository>(); var taskGradeList = viewTaskRepository.GetViewTaskByIds(new int[] { taskId }).ToList(); var blTeamGradeDetail = new BLTeamGradeDetail(); var teamGradeDetailList = blTeamGradeDetail.GetAllTeamGradeDetailByTaskIds(taskTeamRepositoryList.Select(t => t.TaskId).Distinct().ToArray()).ToList(); var taskBaseGradeList = (from task in taskTeamRepositoryList group task by new { task.TaskId, task.TaskName } into g select new VmTaskBaseGrade { TaskId = g.Key.TaskId, TaskName = g.Key.TaskName, GradeList = (from gt in taskGradeList where gt.Id == g.Key.TaskId select new VmGrade { Id = gt.GradeId, Name = gt.Grade }).ToList(), TeamGradeList = (from team in g.ToList() group team by new { team.TeamId, team.TeamName } into tg select new VmTeamGrade { TeamId = tg.Key.TeamId, TeamName = tg.Key.TeamName, }).ToList() }).ToList(); foreach (var taskBaseGrade in taskBaseGradeList) { foreach (var team in taskBaseGrade.TeamGradeList) { team.GradeReportList = new List <VmGradeReport>(); foreach (var grade in taskBaseGrade.GradeList) { team.GradeReportList.Add(new VmGradeReport { GradeId = grade.Id, GradeType = grade.Name, Average = GetAverageTotal(teamGradeDetailList, taskBaseGrade.TaskId, team.TeamId, grade.Id) }); } } } return(taskBaseGradeList); }