示例#1
0
        public ActionResult ExportToExcel(int?leagueId, int?teamId, int?currentLeagueId, int?seasonId, FormCollection form)
        {
            var  xlsService = new ExcelGameService();
            var  gameIds    = Session["GameIds"] != null ? (int[])Session["GameIds"] : new int[] { };
            var  games      = new List <ExcelGameDto>();
            bool isBasketBallOrWaterPolo = false;

            if (leagueId.HasValue)
            {
                isBasketBallOrWaterPolo = leagueRepo.IsBasketBallOrWaterPoloLeague(leagueId.Value);
                games = xlsService.GetLeagueGames(leagueId.Value, gameIds).ToList();
            }
            else if (teamId.HasValue)
            {
                if (!seasonId.HasValue)
                {
                    seasonId = teamRepo.GetSeasonIdByTeamId(teamId.Value, DateTime.Now);
                }
                isBasketBallOrWaterPolo = seasonsRepository.IsBasketBallOrWaterPoloSeason(seasonId.Value);
                if (currentLeagueId.HasValue)
                {
                    games = xlsService.GetTeamGames(teamId.Value, currentLeagueId.Value, gameIds, seasonId).ToList();
                }
                else
                {
                    games = xlsService.GetTeamGames(teamId.Value, gameIds, seasonId).ToList();
                }
            }
            return(ToExcel(games, isBasketBallOrWaterPolo));
        }
示例#2
0
        public ActionResult ExportToExcelUnion(List <int> leaguesId, int sortType, FormCollection form)
        {
            var xlsService = new ExcelGameService();
            var gameIds    = String.IsNullOrWhiteSpace(form["gameIds1"])
             ? new int[] { }
           : form["gameIds1"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)
            .Select(s => int.Parse(s))
            .ToArray();
            bool isBacketBallOrWaterPolo = false;

            var games = xlsService.GetGameCyclesByIdSet(gameIds).ToList();

            if (games?.Count() > 0)
            {
                isBacketBallOrWaterPolo = gamesRepo.IsBasketBallOrWaterPoloGameCycle(games[0].GameId);
            }
            if (sortType == 1)
            {
                games = games.OrderBy(x => x.Date).ToList();
            }
            if (sortType == 2)
            {
                games = games.OrderBy(x => x.Auditorium).ToList();
            }

            return(ToExcel(games, isBacketBallOrWaterPolo));
        }
示例#3
0
        public ActionResult ExportToExcelUnion(List <int> leaguesId, int sortType, int seasonId)
        {
            leaguesId = (List <int>)Session["LeaguesIds"];
            var  xlsService = new ExcelGameService();
            bool isBasketBallOrWaterPolo = false;
            var  games = new List <ExcelGameDto>();

            foreach (var leagueId in leaguesId)
            {
                games.AddRange(xlsService.GetLeagueGames(leagueId, seasonId));
            }

            if (games?.Count() > 0)
            {
                isBasketBallOrWaterPolo = gamesRepo.IsBasketBallOrWaterPoloGameCycle(games[0].GameId);
            }

            if (sortType == 1)
            {
                games = games.OrderBy(x => x.Date).ToList();
            }
            if (sortType == 2)
            {
                games = games.OrderBy(x => x.Auditorium).ToList();
            }

            return(ToExcel(games, isBasketBallOrWaterPolo));
        }
示例#4
0
        public ActionResult ExportToExcel(int?leagueId, int?teamId, int?currentLeagueId, int?seasonId,
                                          int dateFilterType = Schedules.DateFilterPeriod.All,
                                          DateTime?dateFrom  = null, DateTime?dateTo = null)
        {
            var  xlsService              = new ExcelGameService();
            bool userIsEditor            = User.IsInAnyRole(AppRole.Admins, AppRole.Editors, AppRole.Workers);
            var  games                   = new List <ExcelGameDto>();
            bool isBasketBallOrWaterPolo = false;

            if (leagueId.HasValue)
            {
                isBasketBallOrWaterPolo = leagueRepo.IsBasketBallOrWaterPoloLeague(leagueId.Value);
                switch (dateFilterType)
                {
                case Schedules.DateFilterPeriod.BeginningOfMonth:
                    games = xlsService.GetLeagueGames(leagueId.Value, userIsEditor, Schedules.FirstDayOfMonth, null).ToList();
                    break;

                case Schedules.DateFilterPeriod.Ranged:
                    games = xlsService.GetLeagueGames(leagueId.Value, userIsEditor, dateFrom, dateTo).ToList();
                    break;

                default:
                    games = xlsService.GetLeagueGames(leagueId.Value, userIsEditor, null, null).ToList();
                    break;
                }
            }
            else if (teamId.HasValue)
            {
                if (!seasonId.HasValue)
                {
                    seasonId = teamRepo.GetSeasonIdByTeamId(teamId.Value, DateTime.Now);
                }
                isBasketBallOrWaterPolo = seasonsRepository.IsBasketBallOrWaterPoloSeason(seasonId.Value);
                if (currentLeagueId.HasValue)
                {
                    games = xlsService.GetTeamGames(teamId.Value, currentLeagueId.Value, seasonId).ToList();
                }
                else
                {
                    games = xlsService.GetTeamGames(teamId.Value, seasonId).ToList();
                }
            }

            return(ToExcel(games, isBasketBallOrWaterPolo));
        }