Example #1
0
        // GET: CourseMains/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseMain courseMain = db.CourseMains.Find(id);

            if (courseMain == null)
            {
                return(HttpNotFound());
            }
            return(View(courseMain));
        }
Example #2
0
        // GET: CourseMains/Details/5
        public ActionResult Details(int id)
        {
            CourseMain courseMain = db.CourseMains.Find(id);

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

            // Get Course Details (Card of Course)
            var CourseDetail = from cd in db.CourseDetails
                               where cd.CourseID == id
                               select cd;

            ViewBag.ClubName = courseMain.ClubName;

            // Get 9 Holes Total and Store in ViewBag variables
            // Front 9
            ViewBag.FrontWhiteYrds  = cInfo.GetCourseTotal(1, 9, id, "WhiteYrds");
            ViewBag.FrontYellowYrds = cInfo.GetCourseTotal(1, 9, id, "YellowYrds");
            ViewBag.FrontMensPar    = cInfo.GetCourseTotal(1, 9, id, "MensPar");
            ViewBag.FrontRedYrds    = cInfo.GetCourseTotal(1, 9, id, "RedYrds");
            ViewBag.FrontLadiesPar  = cInfo.GetCourseTotal(1, 9, id, "LadiesPar");

            //Back 9
            ViewBag.BackWhiteYrds  = cInfo.GetCourseTotal(10, 18, id, "WhiteYrds");
            ViewBag.BackYellowYrds = cInfo.GetCourseTotal(10, 18, id, "YellowYrds");
            ViewBag.BackMensPar    = cInfo.GetCourseTotal(10, 18, id, "MensPar");
            ViewBag.BackRedYrds    = cInfo.GetCourseTotal(10, 18, id, "RedYrds");
            ViewBag.BackLadiesPar  = cInfo.GetCourseTotal(10, 18, id, "LadiesPar");

            // Totals
            ViewBag.TotalWhiteYrds  = Convert.ToInt32(ViewBag.FrontWhiteYrds + Convert.ToInt32(ViewBag.BackWhiteYrds));
            ViewBag.TotalYellowYrds = Convert.ToInt32(ViewBag.FrontYellowYrds + Convert.ToInt32(ViewBag.BackYellowYrds));
            ViewBag.TotalMensPar    = Convert.ToInt32(ViewBag.FrontMensPar + Convert.ToInt32(ViewBag.BackMensPar));
            ViewBag.TotalRedYrds    = Convert.ToInt32(ViewBag.FrontRedYrds + Convert.ToInt32(ViewBag.BackRedYrds));
            ViewBag.TotalLadiesPar  = Convert.ToInt32(ViewBag.FrontLadiesPar + Convert.ToInt32(ViewBag.BackLadiesPar));

            return(View(CourseDetail.ToList()));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "CourseID,ClubName,WhiteSSS,YellowSSS,RedSSS")] CourseMain courseMain)
        {
            if (ModelState.IsValid)
            {
                db.CourseMains.Add(courseMain);
                db.SaveChanges();

                // Create 18 Hole Details for Main Course Record
                for (int i = 1; i < 19; i++)
                {
                    var cDetail = new Models.CourseDetail();
                    cDetail.CourseID   = courseMain.CourseID;
                    cDetail.HoleNumber = i;

                    db.CourseDetails.Add(cDetail);
                }
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(courseMain));
        }
Example #4
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));
        }