コード例 #1
0
        public static AthleteSpeedPerformanceDTO from(athelete athlete, int meters)
        {
            var speedTests = athlete.speedTest.Where(s => s.meters == meters);

            speedTests = speedTests.OrderBy(s => ((s.hours * 3600) + (s.minutes * 60) + s.seconds + (s.milliseconds * 1.0 / 1000)));
            bool containsElements = speedTests.Count() > 0;

            return(new AthleteSpeedPerformanceDTO()
            {
                athleteId = athlete.id,
                athleteName = $"{athlete.user.firstName}",
                athletePictureUrl = athlete.user.pictureUrl,
                username = athlete.user.username,

                averageHours = containsElements ? (int)speedTests.Average(s => s.hours) : 0,
                averageMinutes = containsElements ? (int)speedTests.Average(s => s.minutes) : 0,
                averageSeconds = containsElements ? (int)speedTests.Average(s => s.seconds) : 0,
                averageMilliseconds = containsElements ? (int)speedTests.Average(s => s.milliseconds) : 0,

                bestMarkHour = containsElements ? speedTests.FirstOrDefault().hours : 0,
                bestMarkMinute = containsElements ? speedTests.FirstOrDefault().minutes : 0,
                bestMarkSecond = containsElements ? speedTests.FirstOrDefault().seconds : 0,
                bestMarkMillisecond = containsElements ? speedTests.FirstOrDefault().milliseconds : 0,

                age = DateTime.Today.Year - athlete.user.birthDate.Year
            });
        }
コード例 #2
0
        public static AthleteSaltabilityPerformanceDTO from(athelete athlete, int saltabilityTestTypeId)
        {
            var jumpTests = athlete.jumpTest.Where(j => j.jumpTestTypeId == saltabilityTestTypeId);

            jumpTests = jumpTests.OrderBy(j => j.distanceResult);
            bool containsElements = jumpTests.Count() > 0;

            return(new AthleteSaltabilityPerformanceDTO()
            {
                athleteId = athlete.id,
                athleteName = $"{athlete.user.firstName}",
                athletePictureUrl = athlete.user.pictureUrl,
                username = athlete.user.username,
                age = DateTime.Today.Year - athlete.user.birthDate.Year,
                averageSaltability = containsElements ? (float)jumpTests.Average(j => j.distanceResult) : 0,
                bestJumpMark = containsElements ? (float)jumpTests.Max(j => j.distanceResult) : 0
            });
        }
コード例 #3
0
        public string PostByAtheleteNameOnCoach(int coachId, string athleteName)
        {
            athelete athleteFinded = context.athelete.Include("user").FirstOrDefault(a => a.user.username == athleteName);

            if (athleteFinded != null)
            {
                coachByAthelete coachByAthl = new coachByAthelete();
                coachByAthl.coachId    = coachId;
                coachByAthl.atheleteId = athleteFinded.id;
                context.coachByAthelete.Add(coachByAthl);
                context.SaveChanges();
                return("Atleta encontrado");
            }
            else
            {
                return("Atleta no encontrado");
            }
        }
コード例 #4
0
ファイル: AthleteDTO.cs プロジェクト: jorgxjr/GroupSportsRepo
 public static AthleteDTO from(athelete x)
 {
     return(new AthleteDTO()
     {
         id = x.id,
         username = x.user.username,
         password = x.user.password,
         userType = x.user.userType,
         firstName = x.user.firstName,
         lastName = x.user.lastName,
         cellPhone = x.user.cellPhone,
         address = x.user.address,
         emailAddress = x.user.emailAddress,
         disciplineName = x.discipline.disciplineName,
         disciplineId = x.disciplineId,
         userId = x.userId,
         pictureUrl = x.user.pictureUrl,
         birthDate = x.user.birthDate
     });
 }