Пример #1
0
 /// <summary>
 /// Finds List of Tournament by given criteria
 /// </summary>
 /// <param name="criteria"> The criteria. </param>
 /// <returns> The <see cref="Tournament"/>. </returns>
 public List <Tournament> Execute(OldTournamentsCriteria criteria)
 {
     return(_unitOfWork.Context.Tournaments
            .Where(t => t.IsArchived == false)
            .Where(t => t.GamesEnd <= criteria.CheckDate)
            .Select(GetTournamentMapping())
            .ToList());
 }
Пример #2
0
        /// <summary>
        /// Finds List of Tournament by given criteria
        /// </summary>
        /// <param name="criteria"> The criteria. </param>
        /// <returns> The <see cref="Tournament"/>. </returns>
        public ICollection <Tournament> Execute(OldTournamentsCriteria criteria)
        {
            return(_unitOfWork.Context.Tournaments
#pragma warning disable S1125 // Boolean literals should not be redundant
                   .Where(t => t.IsArchived == false)
#pragma warning restore S1125 // Boolean literals should not be redundant
                   .Where(t => t.GamesEnd <= criteria.CheckDate)
                   .Select(GetTournamentMapping())
                   .ToList());
        }
        /// <summary>
        /// Method for autho-archiving old tournaments.
        /// Finds old tournaments to be archived.
        /// As we don't have reliable task scheduling at the moment of writing,
        /// we call this method every time user retrieves list of tournaments to make sure we do not show outdated tournaments.
        /// </summary>
        public void ArchiveOld()
        {
            var criteria = new OldTournamentsCriteria {
                CheckDate = TimeProvider.Current.UtcNow.AddYears(-TournamentConstants.YEARS_AFTER_END_TO_BE_OLD)
            };

            // Gets old tournaments that need to be archived
            var old = _getOldTournamentsQuery.Execute(criteria);

            if (Enumerable.Any(old))
            {
                foreach (var item in old)
                {
                    Archive(item);
                }

                _tournamentRepository.UnitOfWork.Commit();
            }
        }