Ejemplo n.º 1
0
        public ActionResult PlayerScoreCard(int?compScoreID, int rndNumber)
        {
            ScoreInfo scoreInfo = new ScoreInfo();

            if (compScoreID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CompScore compScore = db.CompScores.Find(compScoreID);

            int NumberofRnds = pStats.NumberRndsPlayed(Convert.ToInt32(compScore.CompID), compScore.CompPlayerID);

            if (NumberofRnds < rndNumber)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            // Get Course Logo using a stored procedure
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnValue("TigerLineScoresDB")))
            {
                List <String> courseLogo = connection.Query <string>("dbo.spGetLogoImagePath @CourseID", new { CourseID = compScore.CourseID }).ToList();
                ViewBag.CourseLogo = courseLogo[0];
            }

            ViewBag.PHcap        = compScore.PlayerHcap;
            ViewBag.PlayerName   = pStats.GetPlayerName(compScore.CompPlayerID);
            ViewBag.PlayerPhoto  = pStats.GetPlayerPhoto(compScore.CompPlayerID);
            ViewBag.PlayerHomeID = pStats.HomeClubID(compScore.CompPlayerID);
            ViewBag.RndDate      = compScore.RndDate;
            ViewBag.RndNumber    = rndNumber;

            // Score Card Image
            ViewBag.CardImage = compInfo.GetScoreCardImage(compScore.CompScoreID);

            CourseMain courseM = db.CourseMains.Find(compScore.CourseID);

            ViewBag.CourseName = courseM.ClubName;

            CompMain cMain = db.CompMains.Find(compScore.CompID);

            ViewBag.CompName = cMain.CompName;

            // Get the Course Par
            ViewBag.CoursePar = cInfo.GetCoursePar(compScore.CourseID, compScore.TeeColour);

            // Get the NET Points (Gross Points - (CoursePar - SSS))
            ViewBag.NetPoints = compScore.TotalPoints - (ViewBag.CoursePar - compScore.SSS);

            if (compScore == null)
            {
                return(HttpNotFound());
            }

            // Get Course Details depending on course and tee colour selected
            int     courseID  = compScore.CourseID;
            string  teeColour = compScore.TeeColour;
            decimal?PHcap     = compScore.PlayerHcap;

            ViewBag.scoreCard = cInfo.GetCourseDetails(Convert.ToInt32(courseID), teeColour);

            // Get Hole Scores
            ViewBag.CurrentScore = compScore;
            // Front 9 Total Score
            ViewBag.FrontScore = scoreInfo.FrontScore(compScore.CompScoreID);
            // Back 9 Total Score
            ViewBag.BackScore = scoreInfo.BackScore(compScore.CompScoreID);
            // Total Score
            ViewBag.TotalScore = ViewBag.FrontScore + ViewBag.BackScore;

            // Blank Points
            CompPoints compPoints = pScore.GetCompPoints(compScore);

            ViewBag.RndPoints = compPoints;

            // Get Course Totals depending on course and tee colour - Store totals in View bag variables
            CourseTotals cTotals = cInfo.GetCourseTotals(Convert.ToInt32(courseID), teeColour);

            ViewBag.TeeColour = cTotals.teeColour;
            ViewBag.FrontYrds = cTotals.frontYrds;
            ViewBag.BackYrds  = cTotals.backYrds;
            ViewBag.TotalYrds = cTotals.totalYrds;
            ViewBag.FrontPar  = cTotals.frontPar;
            ViewBag.BackPar   = cTotals.backPar;
            ViewBag.TotalPar  = cTotals.totalPar;

            // Store the playing handicap in the ViewBag
            var playingHCap = 0;

            if (PHcap != null)
            {
                playingHCap = Convert.ToInt32(PHcap);
            }
            ViewBag.PHcap = playingHCap;

            return(PartialView("_ScoreCard", compScore));
        }