示例#1
0
        public void UpdateTest()
        {
            var skier = skierDao.FindById(5);

            skier.FirstName = "Franzbert";
            skierDao.Update(skier);
            Assert.True(skierDao.FindById(5).FirstName == "Franzbert");
        }
示例#2
0
        public ActionResult <SkierOutDto> GetById(int id)
        {
            Skier skier = _adoSkierDao.FindById(id);

            if (skier == null)
            {
                return(NotFound());
            }
            return(Ok(SkierOutDto.FromSkier(skier)));
        }
示例#3
0
        public ActionResult <IList <StartListSkierOutDto> > Get(int runningRaceId, int runNo)
        {
            IList <StartListSkierOutDto>  startListSkierOutDtos = new List <StartListSkierOutDto>();
            IEnumerable <StartListMember> startListMembers      = _adoStartListDao.FindAllByRaceIdAndRunNo(runningRaceId, runNo);

            if (startListMembers == null)
            {
                return(NotFound());
            }

            startListMembers = startListMembers.Where(member => member.RunNo == runNo);
            IEnumerable <RaceData> raceDatas = _adoRaceDataDao.FindAllByRaceId(runningRaceId);

            if (raceDatas == null)
            {
                return(NotFound());
            }
            foreach (var startListMember in startListMembers)
            {
                var raceData = raceDatas.FirstOrDefault(data => data.SkierId == startListMember.SkierId);
                if (raceData == null)
                {
                    continue;
                }
                var skier = _adoSkierDao.FindById(raceData.SkierId);
                startListSkierOutDtos.Add(StartListSkierOutDto.FromSkierRaceDataAndStartListMember(skier, raceData, startListMember));
            }

            return(Ok(startListSkierOutDtos));
        }
示例#4
0
        public ActionResult <IList <RankingSkierOutDto> > Get(int runningRaceId, int runNo)
        {
            IList <RankingSkierOutDto> rankingSkierOutDtos = new List <RankingSkierOutDto>();
            IList <RaceData>           finishedStartListMemberRaceDatas = new List <RaceData>();

            if (runNo < 1 || runNo > 2)
            {
                return(BadRequest());
            }
            Race runningRace = _adoRaceDao.FindById(runningRaceId);

            if (runningRace == null)
            {
                return(NotFound());
            }
            IEnumerable <StartListMember> startListMembers = _adoStartListDao.FindAllByRaceIdAndRunNo(runningRaceId, runNo);

            if (startListMembers == null)
            {
                return(NotFound());
            }
            foreach (var startListMember in startListMembers)
            {
                RaceData raceData = _adoRaceDataDao.FindAllBySkierId(startListMember.SkierId)
                                    .FirstOrDefault(data => data.RaceId == runningRaceId);
                if (raceData != null && (!raceData.Finished && !raceData.Disqualified))
                {
                    finishedStartListMemberRaceDatas.Add(raceData);
                }
            }

            foreach (var finishedStartListMemberRaceData in finishedStartListMemberRaceDatas)
            {
                var lastSplitTime = _adoSplitTimeDao.FindByRaceDataId(finishedStartListMemberRaceData.Id)
                                    .FirstOrDefault(splitTimeEntry => (splitTimeEntry.SplittimeNo == runningRace.Splittimes) &&
                                                    splitTimeEntry.RunNo == runNo);
                if (lastSplitTime == null)
                {
                    continue;
                }
                var skier = _adoSkierDao.FindById(finishedStartListMemberRaceData.SkierId);
                rankingSkierOutDtos.Add(new RankingSkierOutDto()
                {
                    FirstName    = skier.FirstName,
                    LastName     = skier.LastName,
                    Nation       = skier.Nation,
                    ProfileImage = skier.ProfileImage,
                    EndTime      = lastSplitTime.Time
                });
            }
            var orderedRankingSkierOutDtos = rankingSkierOutDtos.OrderBy(dto => dto.EndTime);

            rankingSkierOutDtos = orderedRankingSkierOutDtos.ToList();
            for (int i = 1; i <= rankingSkierOutDtos.Count; i++)
            {
                rankingSkierOutDtos[i - 1].Ranking = i;
            }
            return(Ok(rankingSkierOutDtos));
        }