コード例 #1
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
        public IEnumerable <Game> GetGamesByRoundsForPeriod(DateTime startDate, DateTime endDate, IEnumerable <int> roundIds)
        {
            string cacheKey = GetStringMethodKey(nameof(GetGamesByRoundsForPeriod), startDate, endDate, roundIds);

            IEnumerable <Game> result = Cache.GetOrCreate(cacheKey, () => { return(DalGames.GetGamesByRoundsForPeriod(startDate, endDate, roundIds)); });

            return(result);
        }
コード例 #2
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
        public IEnumerable <Game> GetRoundGames(int roundId)
        {
            string cacheKey = GetStringMethodKey(nameof(GetRoundGames), roundId);

            IEnumerable <Game> result = Cache.GetOrCreate(cacheKey, () => { return(DalGames.GetRoundGames(roundId)); });

            return(result);
        }
コード例 #3
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
        public IEnumerable <Game> GetGamesByRounds(IEnumerable <int> roundIds)
        {
            string cacheKey = GetStringMethodKey(nameof(GetGamesByRounds), roundIds);

            IEnumerable <Game> result = Cache.GetOrCreate(cacheKey, () => { return(DalGames.GetGamesByRounds(roundIds)); });

            return(result);
        }
コード例 #4
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
        public IEnumerable <Game> GetTeamGames(int teamId, IEnumerable <int> tourneyIds, DateTime date, int daysShift)
        {
            DateTime dateStart = AddDaysSoft(date, -daysShift);
            DateTime dateEnd   = AddDaysSoft(date, daysShift);

            string cacheKey = GetStringMethodKey(nameof(GetTeamGames), teamId, tourneyIds, date, daysShift);

            IEnumerable <Game> result = Cache.GetOrCreate(cacheKey, () => { return(DalGames.GetTeamGames(teamId, tourneyIds, dateStart, dateEnd)); });

            return(result);
        }
コード例 #5
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
        public bool SaveGameNote(int gameId, string note)
        {
            Game game = DalGames.GetGame(gameId);

            if (game == null)
            {
                return(false);
            }

            game.Note = note;

            return(DalGames.SaveGame(game).Id > 0);
        }
コード例 #6
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
        public IEnumerable <Game> GetTeamActualRoundGames(int teamId, IEnumerable <int> roundIds, DateTime date)
        {
            if (Guard.IsEmptyIEnumerable(roundIds))
            {
                return(new Game[0]);
            }

            Game nearestGame = DalGames.GetTeamNearestGame(teamId, roundIds, date);

            IEnumerable <Game> roundGames = null;

            if (nearestGame != null)
            {
                roundGames = DalGames.GetRoundGames(nearestGame.roundId).OrderBy(g => g.GameDate);
            }

            return(roundGames ?? new Game[0]);
        }
コード例 #7
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
 public int RemoveGame(int gameId, bool removeProtocol = true)
 {
     return(DalGames.RemoveGame(gameId, removeProtocol));
 }
コード例 #8
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
        public IEnumerable <Game> GetTeamPrevNextGamesForce(int teamId, IEnumerable <int> tourneyIds, DateTime date, int daysShift)
        {
            const int gamesCount = 2;
            var       games      = new List <Game>();

            DateTime dateStart = AddDaysSoft(date, -daysShift);
            DateTime dateEnd   = AddDaysSoft(date, daysShift);

            List <Game> gamesPrevNext = DalGames.GetTeamGames(teamId, tourneyIds, dateStart, dateEnd)
                                        .OrderByDescending(g => g.GameDate)
                                        .ToList();

            Game game1;
            Game game2;

            // games in period
            if (gamesPrevNext.Any())
            {
                game1 = gamesPrevNext.Where(g => g.Played).FirstOrDefault();

                if (game1 != null)
                {
                    games.Add(game1);
                }
                else
                {
                    game1 = gamesPrevNext.Last();
                    gamesPrevNext.RemoveAt(gamesPrevNext.Count - 1);
                }

                if (gamesPrevNext.Any())
                {
                    game2 = gamesPrevNext.Where(g => !g.Played && g.GameDate > game1.GameDate).LastOrDefault();

                    if (game2 != null)
                    {
                        games.Add(game2);
                    }
                }

                if (games.Count == gamesCount)
                {
                    return(games);
                }
            }
            // games after
            else
            {
                dateEnd = DateTime.MaxValue;
            }

            gamesPrevNext = DalGames.GetTeamGames(teamId, tourneyIds, dateStart, dateEnd)
                            .OrderByDescending(g => g.GameDate)
                            .ToList();

            if (gamesPrevNext.Any())
            {
                while (gamesPrevNext.Any() && games.Count < gamesCount)
                {
                    games.Add(gamesPrevNext.Last());
                    gamesPrevNext.RemoveAt(gamesPrevNext.Count - 1);
                }

                if (games.Count == gamesCount)
                {
                    return(games);
                }
            }

            // games before
            dateStart = DateTime.MinValue;
            // no games before next was added earlier
            if (!games.Any() && games.Count < gamesCount)
            {
                gamesPrevNext = DalGames.GetTeamGames(teamId, tourneyIds, dateStart, dateEnd)
                                .OrderByDescending(g => g.GameDate)
                                .ToList();

                if (gamesPrevNext.Any())
                {
                    while (gamesPrevNext.Any() && games.Count < gamesCount)
                    {
                        games.Insert(0, gamesPrevNext.First());
                        gamesPrevNext.RemoveAt(0);
                    }

                    if (games.Count == gamesCount)
                    {
                        return(games);
                    }
                }
            }

            return(games);
        }
コード例 #9
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
 public IEnumerable <Game> GetGamesByTourneyBetweenTeams(int tourneyId, IEnumerable <int> teamIds)
 {
     return(DalGames.GetGamesByTourneyBetweenTeams(tourneyId, teamIds));
 }
コード例 #10
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
 public IEnumerable <Game> GetGamesByTourney(int tourneyId)
 {
     return(DalGames.GetGamesByTourney(tourneyId));
 }
コード例 #11
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
 public Game SaveGame(Game entity)
 {
     return(DalGames.SaveGame(entity));
 }
コード例 #12
0
ファイル: GameBll.cs プロジェクト: DelLitt/FCWebSite
 public Game GetGame(int id)
 {
     return(DalGames.GetGame(id));
 }