예제 #1
0
        public ActionResult Edit([Bind(Include = "CompScoreID,CompID,CompPlayerID,CourseID,TeeColour,SSS,Hole1,Hole2,Hole3,Hole4,Hole5,Hole6,Hole7,Hole8,Hole9,Hole10,Hole11,Hole12,Hole13,Hole14,Hole15,Hole16,Hole17,Hole18,PlayerHcap,RndDate")] CompScore compScore)
        {
            if (ModelState.IsValid)
            {
                // Create the Points Score
                CompPoints compPoints = pScore.GetCompPoints(compScore);
                ViewBag.RndPoints = compPoints;

                // Get the points total
                compScore.TotalPoints = compPoints.TotalPoints;
                int compID = compScore.CompID;

                db.Entry(compScore).State = EntityState.Modified;
                db.SaveChanges();

                // Go to the updated league table
                return(RedirectToAction("Index", "Players", new { compID }));
            }
            return(View(compScore));
        }
예제 #2
0
        public ActionResult ScoreCardEdit(int compScoreID)
        {
            CompScore compScore = db.CompScores.Find(compScoreID);

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

            CourseInfo cInfo = new CourseInfo();

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

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

            // 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;

            ViewBag.PHcap = compScore.PlayerHcap;

            // Store the current scores in a viewbag variable.
            ViewBag.CurrentScore = compScore;

            // Store the current points in a viewbag variable
            CompPoints compPoints = pScore.GetCompPoints(compScore);

            ViewBag.RndPoints = compPoints;

            return(PartialView("_ScoreCard"));
        }
예제 #3
0
        public ActionResult ScoreCard(int?id, string teeColour, int?PHcap)
        {
            CourseInfo cInfo = new CourseInfo();

            // Get Course Details depending on course and tee colour selected
            ViewBag.scoreCard = cInfo.GetCourseDetails(Convert.ToInt32(id), teeColour);

            // Blank Scores
            var compScore = new CompScore();

            ViewBag.CurrentScore = compScore;
            // 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(id), 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"));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "CompScoreID,CompID,CompPlayerID,CourseID,TeeColour,SSS,Hole1,Hole2,Hole3,Hole4,Hole5,Hole6,Hole7,Hole8,Hole9,Hole10,Hole11,Hole12,Hole13,Hole14,Hole15,Hole16,Hole17,Hole18,PlayerHcap,RndDate,ImageID")] CompScore compScore)
        {
            if (ModelState.IsValid)
            {
                // Create the points model for this rounds score
                CompPoints compPoints = pScore.GetCompPoints(compScore);
                ViewBag.RndPoints = compPoints;

                // Get the points total
                compScore.TotalPoints = compPoints.TotalPoints;

                db.CompScores.Add(compScore);
                db.SaveChanges();
                int compScoreID = compScore.CompScoreID;
                int compID      = compScore.CompID;
                int imageID     = Convert.ToInt32(compScore.ImageID);

                // Uploaded score card processed
                ScoreCardImage scImage = db.ScoreCardImages.Find(imageID);
                scImage.Processed = true;

                // move score card image to Score Cards/Completed  folder
                string sourceFile      = Server.MapPath(@scImage.CardImage);
                string destinationFile = Server.MapPath(@scImage.CardImage.Replace("Pending", "Completed"));
                System.IO.File.Move(sourceFile, destinationFile);

                scImage.CardImage       = scImage.CardImage.Replace("Pending", "Completed");
                db.Entry(scImage).State = EntityState.Modified;
                db.SaveChanges();

                // Go to the updated league table
                return(RedirectToAction("Index", "Players", new { compID }));
            }

            return(Redirect(Request.UrlReferrer.PathAndQuery));
        }
예제 #5
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));
        }