예제 #1
0
        public ActionResult SeasonTotals(ReportModel reportModel)
        {
            // Get current season and load seasons list for Season selector
            int seasonID = reportModel.Season != 0
                ? reportModel.Season
                : SessionVariables.SeasonID.HasValue
                    ? (int)SessionVariables.SeasonID
                    : Season.CurrentSeason;

            // Store selected season on session and in model
            SessionVariables.SeasonID = reportModel.Season = seasonID;

            ViewBag.SeasonList = Season.Seasons;

            switch (reportModel.ReportType)
            {
            case ReportModel.ReportTypes.GrossScore:
                reportModel.Data   = Reports.AverageGrossPerOuting(reportModel.Season);
                reportModel.Legend = new List <string> {
                    "Does not include Par 3 courses."
                };
                break;

            case ReportModel.ReportTypes.NetScore:
                reportModel.Data   = Reports.AverageNetPerOuting(reportModel.Season);
                reportModel.Legend = new List <string> {
                    "Does not include Par 3 courses."
                };
                break;

            case ReportModel.ReportTypes.TotalSkins:
                reportModel.Data   = Reports.TotalSkins(reportModel.Season);
                reportModel.Legend = new List <string> {
                    "Reported as <b><i>total</i></b> <font size='+1'>[</font><b><i>won by flip</i></b>]"
                };
                break;

            case ReportModel.ReportTypes.AvgSkinsPerOuting:
                reportModel.Data = Reports.AverageSkinsPerOuting(reportModel.Season);
                break;

            case ReportModel.ReportTypes.TotalHics:
                reportModel.Data = Reports.TotalHICS(reportModel.Season);
                break;

            case ReportModel.ReportTypes.AvgHicsPerOuting:
                reportModel.Data = Reports.AverageHICSPerOuting(reportModel.Season);
                break;

            case ReportModel.ReportTypes.TotalKPs:
                reportModel.Data = Reports.TotalKPs(reportModel.Season);
                break;

            case ReportModel.ReportTypes.AvgKPsPerOuting:
                reportModel.Data = Reports.AverageKPsPerOuting(reportModel.Season);
                break;

            case ReportModel.ReportTypes.TotalWinnings:
                reportModel.Data = Reports.TotalTransactions(false, reportModel.Season);
                break;

            case ReportModel.ReportTypes.TotalWinningsPerOuting:
                reportModel.Data = Reports.TotalTransactionsPerOuting(reportModel.Season);
                break;

            case ReportModel.ReportTypes.UnsettledWinnings:
                reportModel.Data = Reports.TotalTransactions(true, reportModel.Season);
                break;

            case ReportModel.ReportTypes.AveragePar3:
                reportModel.Data   = Reports.AverageParScore(3, reportModel.Season);
                reportModel.Legend = new List <string> {
                    "Does not include Par 3 courses."
                };
                break;

            case ReportModel.ReportTypes.AveragePar4:
                reportModel.Data = Reports.AverageParScore(4, reportModel.Season);
                break;

            case ReportModel.ReportTypes.AveragePar5:
                reportModel.Data = Reports.AverageParScore(5, reportModel.Season);
                break;
            }

            // Put player list in ViewBag for use in display
            Dictionary <int, Player> pList = Player.GetPlayersDictionary(true);

            ViewBag.Players = pList;

            // Put player outing counts for season in ViewBag for use in display
            Dictionary <int, int> countList = Player.GetPlayerOutingCounts(reportModel.Season);

            ViewBag.PlayerOutingCounts = countList;

            return(View(reportModel));
        }