Example #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));
        }
Example #2
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));
        }