Beispiel #1
0
        public IEnumerable <Jump> GetAllForAthlete(int idAthlete)
        {
            ICompetitionRepository competitionRepository = new CompetitionRepository(context: _context);
            IEliminationRepository eliminationRepository = new EliminationRepository(_context);
            IContestRepository     contestRepository     = new ContestRepository(_context);

            var         competitions = competitionRepository.GetAllForAthlete(idAthlete);
            List <Jump> result       = new List <Jump>();

            foreach (var competition in competitions)
            {
                var elimination = eliminationRepository.GetEliminationByCompetitionID(competition.IdCompetition);
                var contest     = contestRepository.GetContestByCompetitionID(competition.IdCompetition);

                if (elimination != null)
                {
                    var jumps = GetAllForElimination(elimination.IdElimination).ToList();
                    result = result.Concat(second: jumps).ToList();
                }
                if (contest != null)
                {
                    var jumps = GetAllForContest(contest.IdContest).ToList();
                    result = result.Concat(second: jumps).ToList();
                }
            }

            return(result);
        }
Beispiel #2
0
        private IEnumerable <JumpChartDTO> GetJumpsForChart(DateTime beginDate, DateTime endDate, int id)
        {
            ICompetitionRepository competitionRepository = new CompetitionRepository(context: _context);
            IEliminationRepository eliminationRepository = new EliminationRepository(_context);
            IContestRepository     contestRepository     = new ContestRepository(_context);

            List <JumpChartDTO> result = new List <JumpChartDTO>();

            var competitions = competitionRepository.GetAllForAthlete(id).Where(x => x.BeginDate >= beginDate && x.EndDate <= endDate).ToList();

            foreach (var competition in competitions)
            {
                var elimination = eliminationRepository.GetEliminationByCompetitionID(competition.IdCompetition);
                var contest     = contestRepository.GetContestByCompetitionID(competition.IdCompetition);

                if (elimination != null)
                {
                    var jump = GetAllForElimination(elimination.IdElimination).Where(x => x.IdJumpStatus1 == 1 || x.IdJumpStatus2 == 1 || x.IdJumpStatus3 == 1).OrderByDescending(x => x.Height).FirstOrDefault();
                    if (jump != null)
                    {
                        result.Add(new JumpChartDTO()
                        {
                            DateOfCompetition = elimination.EliminationDate, MaxHeight = jump.Height
                        });
                    }
                }
                if (contest != null)
                {
                    var jump = GetAllForContest(contest.IdContest).Where(x => x.IdJumpStatus1 == 1 || x.IdJumpStatus2 == 1 || x.IdJumpStatus3 == 1).OrderByDescending(x => x.Height).FirstOrDefault();
                    if (jump != null)
                    {
                        result.Add(new JumpChartDTO()
                        {
                            DateOfCompetition = contest.ContestDate, MaxHeight = jump.Height
                        });
                    }
                }
            }
            return(result);
        }