Example #1
0
        // GET: Scores/Edit/5
        public ActionResult Edit(int?CompScoreID)
        {
            if (CompScoreID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CompScore compScore = db.CompScores.Find(CompScoreID);

            ViewBag.PHcap      = compScore.PlayerHcap;
            ViewBag.PlayerName = pStats.GetPlayerName(compScore.CompPlayerID);

            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());
            }
            return(View(compScore));
        }
Example #2
0
        public ActionResult DeleteRnd(int compScoreID)
        {
            CompScore compScore    = db.CompScores.Find(compScoreID);
            int       compID       = compScore.CompID;
            int       compPlayerID = compScore.CompPlayerID;

            db.CompScores.Remove(compScore);
            db.SaveChanges();
            return(RedirectToAction("Index", new { compID, compPlayerID }));
        }
Example #3
0
        // Get the Selected Course SSS and return via a Json call
        public ActionResult CourseSSS(int id, string teecolour)
        {
            CourseInfo cinfo     = new CourseInfo();
            CompScore  compscore = new CompScore();

            {
                compscore.CourseID = id;
                compscore.SSS      = cinfo.GetCourseSSS(id, teecolour);
            };

            return(Json(new { newcompScore = compscore }, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        // GET: Scores/Create
        public ActionResult Create(int compID, int userID, int courseID, string teeColour, int SSS, DateTime rndDate, string scorecardImage, int imageID)
        {
            // Set default Values for the CompScore model initial view
            var scoresModel = new CompScore();

            // Get compPlayerID
            var pStats       = new PlayerStats();
            int compPlayerID = pStats.GetcompPlayerID(userID, compID);

            // Populate the ScoresModel
            scoresModel.CompID       = compID;
            scoresModel.CourseID     = courseID;
            scoresModel.CompPlayerID = compPlayerID;
            scoresModel.TeeColour    = teeColour;
            scoresModel.SSS          = SSS;
            scoresModel.ImageID      = imageID;

            ViewBag.RndDate   = rndDate;
            ViewBag.cardImage = scorecardImage;

            // Get Competition Name
            CompMain compMain = db.CompMains.Find(compID);

            ViewBag.CompName = compMain.CompName;
            ViewBag.CompID   = compID;

            // Get Player Name
            CompPlayer compPlayer = db.CompPlayers.Find(compPlayerID);
            User       users      = db.Users.Find(userID);

            ViewBag.PlayerName = users.UserName;

            // Get Players Current Handicap
            ViewBag.Hcap  = pStats.CurrentHcap(compPlayerID);
            ViewBag.PHcap = Math.Round(ViewBag.HCap, MidpointRounding.AwayFromZero);

            // Get Club Names For Drop Down List
            var courseInfo = new CourseInfo();

            ViewBag.CourseList = courseInfo.GetCourseList();

            // Populate variable to Tee Colour ddl
            ViewBag.TeeColourList = new SelectList(new[]
            {
                new { ID = "White", Name = "White" },
                new{ ID = "Yellow", Name = "Yellow" },
                new{ ID = "Red", Name = "Red" },
            }, "ID", "Name");

            return(View(scoresModel));
        }
Example #5
0
        // GET: Scores/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CompScore compScore = db.CompScores.Find(id);

            if (compScore == null)
            {
                return(HttpNotFound());
            }
            return(View(compScore));
        }
Example #6
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));
        }
Example #7
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"));
        }
Example #8
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"));
        }
Example #9
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));
        }
Example #10
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));
        }