// GET: Scores public ActionResult ClubPlayerRnds(int compID, int courseID) { CompMain cMain = db.CompMains.Find(compID); var playerRnds = (from cs in db.CompScores join cp in db.CompPlayers on cs.CompPlayerID equals cp.CompPlayerID join pr in db.Profiles on cp.UserID equals pr.UserID join ur in db.Users on pr.UserID equals ur.UserID where cs.CompID == compID && cs.CourseID == courseID && pr.HomeClubID == courseID orderby cs.RndDate select new RndSummary { CompScoreID = cs.CompScoreID, RndDate = cs.RndDate, TeeColour = cs.TeeColour, RndPoints = cs.TotalPoints, SSS = cs.SSS, Handicap = cs.PlayerHcap, Player = ur.UserName }).ToList(); // Get and store the Total Gross Score and Net Points for each round foreach (var item in playerRnds) { item.NETRndPoints = Convert.ToInt32(item.RndPoints - (cInfo.GetCoursePar(courseID, item.TeeColour) - item.SSS)); item.RndScore = rndSum.GetRndScore(item.CompScoreID); } // Sort Club Player Rounds into NET Points Order var sortedRnds = from sr in playerRnds orderby sr.NETRndPoints descending select sr; // Get Competition Name, Player Name, Current Handicap and Player Photo ViewBag.CompName = cMain.CompName; ViewBag.CompID = cMain.CompID; ViewBag.ClubName = cInfo.GetCourseName(courseID); ViewBag.RndSummary = sortedRnds; return(View()); }
// GET: UpcomingRnds public ActionResult Index(int compPlayerID, int compID) { //Check User is in this Competition CompInfo compInfo = new CompInfo(); int userID = Convert.ToInt32(Session["userid"]); Boolean IsInComp = compInfo.IsUserinComp(compID, userID); if (IsInComp == false) { TempData["FailUpload"] = "You need to be in a competition to register an upcoming round .."; TempData["SuccessUpload"] = null; return(RedirectToAction("Index", "PLayerCompList")); } // Get Players Upcoming Rounds CourseInfo cInfo = new CourseInfo(); var Rnds = from rd in db.UpcomingRnds where rd.CompPlayerID == compPlayerID && rd.CompID == compID orderby rd.RndDate select rd; foreach (var item in Rnds) { item.CourseName = cInfo.GetCourseName(item.CourseID); } // Get Competition Name, Player Name, Current Handicap and Player Photo PlayerStats pStats = new PlayerStats(); CompMain cMain = db.CompMains.Find(compID); ViewBag.PlayerName = pStats.GetPlayerName(compPlayerID); ViewBag.PlayerPhoto = pStats.GetPlayerPhoto(compPlayerID); ViewBag.CurrentHCap = pStats.CurrentHcap(compPlayerID); ViewBag.CompName = cMain.CompName; ViewBag.CompPlayerID = compPlayerID; ViewBag.CompID = compID; return(View(Rnds.ToList())); }
// GET: ScoreCardImages/Create public ActionResult Create(int CompID) { if ((Session["userid"]) != null) { var cardImageModel = new ScoreCardImage(); //Check User is in this Competition CompInfo cInfo = new CompInfo(); int userID = Convert.ToInt32(Session["userid"]); Boolean IsInComp = cInfo.IsUserinComp(CompID, userID); if (IsInComp == false) { TempData["FailUpload"] = "You need to be in this competition to upload a score card .."; TempData["SuccessUpload"] = null; return(RedirectToAction("Index", "PLayerCompList")); } // default players home course var pStats = new PlayerStats(); cardImageModel.UserID = userID; // competition name var compInfo = new CompInfo(); ViewBag.CompName = compInfo.GetCompetitonName(CompID); cardImageModel.CompID = CompID; // User Name ViewBag.UserName = Session["UserName"]; //CompPlayerID ViewBag.CompPlayerID = Session["CompPlayerID"]; // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.CourseList = courseInfo.GetCourseList(); // Tee Colour List List <SelectListItem> teecolor = new List <SelectListItem>(); teecolor.Add(new SelectListItem() { Text = "White", Value = "White" }); teecolor.Add(new SelectListItem() { Text = "Yellow", Value = "Yellow" }); teecolor.Add(new SelectListItem() { Text = "Red", Value = "Red" }); ViewBag.TeeColour = teecolor; // List of Upcoming Rounds int compPlayerID = Convert.ToInt32(Session["CompPlayerID"]); var Rnds = from rd in db.UpcomingRnds where rd.CompPlayerID == compPlayerID && rd.CompID == CompID orderby rd.RndDate select rd; int rndCount = 1; int upcomingCourseID = 0; DateTime upcomingRndDate = new DateTime(); string upcomingTeeColor = "Yellow"; string upcomingNote = ""; foreach (var item in Rnds) { item.CourseName = courseInfo.GetCourseName(item.CourseID); if (rndCount == 1) { upcomingCourseID = item.CourseID; upcomingRndDate = Convert.ToDateTime(item.RndDate); upcomingNote = item.Note; if (item.RndType == "Competition") { upcomingTeeColor = "White"; } } rndCount += 1; } ViewBag.UpcomingRnds = Rnds.ToList(); // Pre-Populate the Model Items with the FIRST Upcoming Rnd cardImageModel.CourseID = upcomingCourseID; cardImageModel.RoundDate = upcomingRndDate; cardImageModel.TeeColour = upcomingTeeColor; cardImageModel.Note = upcomingNote; return(View(cardImageModel)); } return(RedirectToAction("Index", "Home")); }