Esempio n. 1
0
        public async Task <IList <RecordTime> > GetRecordsBrokeAsync(IDisciplineCalculator calculator, Distance distance, PersonCompetitor competitor, TimeSpan time)
        {
            if (distance.Competition == null)
            {
                throw new ArgumentNullException(nameof(distance), Resources.DistanceCompetitionIsNull);
            }
            if (competitor.Person == null)
            {
                throw new ArgumentNullException(nameof(competitor), Resources.PersonCompetitorPersonIsNull);
            }

            var season = calculator.Season(distance.Competition.Starts);
            var age    = calculator.SeasonAge(season, competitor.Person.BirthDate);

            return(await(from rt in context.RecordTimes
                         where rt.LicenseIssuerId == distance.Competition.LicenseIssuerId &&
                         rt.Discipline == distance.Competition.Discipline &&
                         rt.DistanceDiscipline == distance.Discipline &&
                         rt.Distance == distance.Value &&
                         rt.Gender == competitor.Person.Gender &&
                         ((rt.Type == RecordType.National || rt.Type == RecordType.World) ||
                          (rt.Type == RecordType.Track && rt.VenueCode == distance.VenueCode) ||
                          (rt.Type == RecordType.TrackAge && rt.VenueCode == distance.VenueCode && rt.FromAge <= age && rt.ToAge >= age)) &&
                         time < rt.Time
                         select rt).ToListAsync());
        }
Esempio n. 2
0
 public static int Season(this IDisciplineCalculator calculator, DateTime?reference = null)
 {
     reference = reference ?? DateTime.UtcNow.Date;
     return(calculator.Season(reference.Value));
 }