コード例 #1
0
        internal static IEnumerable <Attempt> GetDataFromDB(IDbContextFactory <WeightliftingContext> contextFactory, AttemptPanel attemptPanel)
        {
            using var context = contextFactory.CreateDbContext();
            var resultAttemtps = context.Attempts.Where(attempt => (attemptPanel.MenIsIncluded && attemptPanel.WomenIsIncluded ||
                                                                    (attemptPanel.MenIsIncluded ? attempt.Athlete.Sex == Men :
                                                                     attemptPanel.WomenIsIncluded && attempt.Athlete.Sex == Women)) &&
                                                        attempt.Date >= attemptPanel.DateLowerLimit && attempt.Date <= attemptPanel.DateUpperLimit &&
                                                        (attempt.Exercise.Name == (attemptPanel.TotalIsIncluded ? Total : null) ||
                                                         attempt.Exercise.Name == (attemptPanel.SnatchIsIncluded ? Snatch : null) ||
                                                         attempt.Exercise.Name == (attemptPanel.CleanAndPressIsIncluded ? Press : null) ||
                                                         attempt.Exercise.Name == (attemptPanel.CleanAndJerkIsIncluded ? CleanAndJerk : null)) &&
                                                        (attemptPanel.Competition == null || attempt.Competition.Name == attemptPanel.Competition) &&
                                                        (attemptPanel.AthleteName == null || attempt.Athlete.Name == attemptPanel.AthleteName) &&
                                                        attempt.AthleteWeight >= attemptPanel.WeightLowerLimit && attempt.AthleteWeight <= attemptPanel.WeightUpperLimit &&
                                                        attempt.Result >= attemptPanel.ResultLowerLimit && attempt.Result <= attemptPanel.ResultUpperLimit &&
                                                        attempt.IsDsq == attemptPanel.IsDisqualified)
                                 .Select(attempt => new Attempt
            {
                AthleteName    = attempt.Athlete.Name,
                Sex            = attempt.Athlete.Sex,
                Competition    = attempt.Competition.Name,
                Excercise      = attempt.Exercise.Name,
                Result         = attempt.Result,
                WeightCategory = context.AttemptCategory.Single(category => category.AttemptId == attempt.Id).Category.Name
            });

            return(resultAttemtps.ToArray());
        }
コード例 #2
0
 public IEnumerable <Attempt> FindData(AttemptPanel attemptPanel)
 {
     return(SearchHelper.GetDataFromDB(_contextFactory, attemptPanel));
 }