public ActionResult ShowUser(int UserID) { var UserProfile = (from ur in db.Users join pr in db.Profiles on ur.UserID equals pr.UserID where ur.UserID == UserID select new UserView { UserID = ur.UserID, UserName = ur.UserName, Email = ur.Email, Password = ur.Password, Admin = ur.Admin, Photo = pr.Photo, Handicap = pr.Handicap, HomeClubID = pr.HomeClubID }).SingleOrDefault(); // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.HomeClubID = courseInfo.GetCourseList(); return(PartialView("_UserDetails", UserProfile)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var UserProfile = from ur in db.Users join pr in db.Profiles on ur.UserID equals pr.UserID where ur.UserID == id select new UserView { UserID = ur.UserID, UserName = ur.UserName, Email = ur.Email, Password = ur.Password, Admin = ur.Admin, Photo = pr.Photo, Handicap = pr.Handicap, HomeClubID = pr.HomeClubID }; UserView uView = new UserView(); foreach (var item in UserProfile) { uView = item; } // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.HomeClubID = courseInfo.GetCourseList(); if (UserProfile == null) { return(HttpNotFound()); } return(View(uView)); }
// GET: Register public ActionResult Index() { // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.CourseList = courseInfo.GetCourseList(); return(View(new UserProfile())); }
public ActionResult EclecticTable(int compID, int courseID) { // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.CourseList = courseInfo.GetCourseList(); ViewBag.CompID = compID; ViewBag.CourseID = courseID; // Return List to View return(View()); }
// 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)); }
// GET: Profiles/Edit/5 public ActionResult Edit() { if (Session["userid"] == null) { return(RedirectToAction("Index", "Home")); } // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.CourseList = courseInfo.GetCourseList(); // Get the user record User user = db.Users.Find(Session["userid"]); var userID = user.UserID; // Get the Profile record int profileID = 0; var getprofiles = from gp in db.Profiles where gp.UserID == userID select gp; foreach (var pro in getprofiles) { profileID = pro.ProfileID; } Profile profile = db.Profiles.Find(profileID); // Populate the UserProfile Model UserProfile userProfile = new UserProfile(); userProfile.UserID = userID; userProfile.UserName = user.UserName; userProfile.Email = user.Email; userProfile.ProfileID = profile.ProfileID; userProfile.HomeCourseID = Convert.ToInt32(profile.HomeClubID); userProfile.Handicap = Convert.ToDecimal(profile.Handicap); userProfile.Photo = profile.Photo; //Get User Name from the user table ViewBag.UserName = user.UserName; if (profile == null) { return(HttpNotFound()); } return(View(userProfile)); }
// GET: ScoreCardImages/Edit/5 public ActionResult Edit(int?imageID) { if (imageID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ScoreCardImage scoreCardImage = db.ScoreCardImages.Find(imageID); if (scoreCardImage == null) { return(HttpNotFound()); } // competition name var compInfo = new CompInfo(); ViewBag.CompName = compInfo.GetCompetitonName(scoreCardImage.CompID); // User Name ViewBag.UserName = Session["UserName"]; // 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; return(View(scoreCardImage)); }
// GET: UpcomingRnds/Create public ActionResult Create(int compPlayerID, int compID) { // 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; // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.CourseList = courseInfo.GetCourseList(); // default players home course var upcomingRnd = new UpcomingRnd(); upcomingRnd.CourseID = pStats.HomeClubID(compPlayerID); upcomingRnd.CompPlayerID = compPlayerID; // Options for Round Type - Competition or Practice List <SelectListItem> rndType = new List <SelectListItem>(); rndType.Add(new SelectListItem() { Text = "Competiton", Value = "Competition" }); rndType.Add(new SelectListItem() { Text = "Practice", Value = "Practice" }); ViewBag.RndType = rndType; return(View(upcomingRnd)); }
// GET: UpcomingRnds/Edit/5 public ActionResult Edit(int?RndID) { if (RndID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UpcomingRnd upcomingRnd = db.UpcomingRnds.Find(RndID); // Get Competition Name, Player Name, Current Handicap and Player Photo PlayerStats pStats = new PlayerStats(); CompMain cMain = db.CompMains.Find(upcomingRnd.CompID); ViewBag.PlayerName = pStats.GetPlayerName(upcomingRnd.CompPlayerID); ViewBag.PlayerPhoto = pStats.GetPlayerPhoto(upcomingRnd.CompPlayerID); ViewBag.CurrentHCap = pStats.CurrentHcap(upcomingRnd.CompPlayerID); ViewBag.CompName = cMain.CompName; // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.CourseList = courseInfo.GetCourseList(); // Options for Round Type - Competition or Practice List <SelectListItem> rndType = new List <SelectListItem>(); rndType.Add(new SelectListItem() { Text = "Competiton", Value = "Competition" }); rndType.Add(new SelectListItem() { Text = "Practice", Value = "Practice" }); ViewBag.RndType = rndType; return(View(upcomingRnd)); }
public ActionResult Edit([Bind(Include = "ImageID,CompID,CardImage,Processed,Note,UserID,RoundDate,CourseID,TeeColour,SSS")] ScoreCardImage scoreCardImage) { if (ModelState.IsValid) { string scorecardfileName = ""; HttpPostedFileBase scorecard = Request.Files["UploadScoreCard"]; if (scorecard.FileName != "" && scoreCardImage.UserID != null) //Deal with New Score Card Image { scorecardfileName = scoreCardImage.UserID + new FileInfo(scorecard.FileName).Name; string path = Path.Combine(Server.MapPath("~/ScoreCards/Pending"), scorecardfileName); //Reduce size of file if required and save in large folder WebImage img = new WebImage(scorecard.InputStream); if (img.Height > 1200) { img.Resize(1200, 1200, true); } img.Save(path); TempData["FailUpload"] = null; TempData["SuccessUpload"] = "Your NEW score card image has been successfully uploaded"; // Save the Score Card Image scoreCardImage.CardImage = "/ScoreCards/Pending/" + scorecardfileName; } else { TempData["SuccessUpload"] = "Your pending score card has been successfully edited"; } db.Entry(scoreCardImage).State = EntityState.Modified; db.SaveChanges(); // Send email to Admin to inform of edited score card image. MessageInfo messageInfo = new MessageInfo(); UserInfo userInfo = new UserInfo(); var AllAdmin = userInfo.GetAllAdmin(); string AdminEmail = ""; string Subject = ""; string Body = ""; string userName = userInfo.GetUserName(Convert.ToInt32(scoreCardImage.UserID)); foreach (var item in AllAdmin) { // messageInfo.CreateMessage(newprofile.UserID, item.UserID, DateTime.Now, user.UserName + " has registered to join Tigerline Scores."); AdminEmail = item.Email; Subject = "PLAYER PENDING SCORECARD EDITED"; Body = "<span style='font-family: Calibri; font-size: 24px; font-weight: bold; color: green'>TIGERLINE SCORES</span><br/><br/>"; Body += "<span style='font-family: Calibri'>Player " + userName + " has edited their pending scorecard ..<br/><br/>"; Body += "<a href='www.tigerlinescores.co.uk'>Tigerline Scores</a>"; messageInfo.SendEmail(AdminEmail, Subject, Body, null); } // 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; } return(View(scoreCardImage)); }
// 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")); }
public ActionResult EclecticLeagueTable(int courseID, int compID) { // Get Players in this competition with matching Home Course and populate the BestScoreView Model var getPlayers = (from cp in db.CompPlayers join ur in db.Users on cp.UserID equals ur.UserID join pr in db.Profiles on ur.UserID equals pr.UserID where cp.CompID == compID && pr.HomeClubID == courseID select new BestScoreView { playerName = ur.UserName, compPlayerID = cp.CompPlayerID }).ToList(); // Loop through each Player and get their BEST List of Scores int loopcount = getPlayers.Count(); for (int i = 0; i < loopcount; i++) { int compPlayerID = getPlayers[i].compPlayerID; // Check player has posted a round var playersRndsCount = (from pr in db.CompScores where pr.CompPlayerID == compPlayerID && pr.CompID == compID && pr.CourseID == courseID select pr).Count(); if (playersRndsCount > 0) { List <int> bestScores = pStats.BestScoreList(compPlayerID, courseID); getPlayers[i].Hole1 = bestScores[0]; getPlayers[i].Hole2 = bestScores[1]; getPlayers[i].Hole3 = bestScores[2]; getPlayers[i].Hole4 = bestScores[3]; getPlayers[i].Hole5 = bestScores[4]; getPlayers[i].Hole6 = bestScores[5]; getPlayers[i].Hole7 = bestScores[6]; getPlayers[i].Hole8 = bestScores[7]; getPlayers[i].Hole9 = bestScores[8]; getPlayers[i].Hole10 = bestScores[9]; getPlayers[i].Hole11 = bestScores[10]; getPlayers[i].Hole12 = bestScores[11]; getPlayers[i].Hole13 = bestScores[12]; getPlayers[i].Hole14 = bestScores[13]; getPlayers[i].Hole15 = bestScores[14]; getPlayers[i].Hole16 = bestScores[15]; getPlayers[i].Hole17 = bestScores[16]; getPlayers[i].Hole18 = bestScores[17]; // Number of Rounds getPlayers[i].NumberOfRnds = playersRndsCount; // Get Total Score getPlayers[i].TotalScore = bestScores.Sum(); // Get Par Score int parScore = getPlayers[i].TotalScore - cInfo.GetCoursePar(courseID, "Yellow"); if (parScore == 0) { getPlayers[i].ParScore = "E"; } else if (parScore > 0) { getPlayers[i].ParScore = "+" + parScore.ToString(); } else { getPlayers[i].ParScore = parScore.ToString(); } } } ; // Sort List for table // Sort list into Points Descending and apply current Position var sortedPlayers = (from sp in getPlayers where sp.TotalScore > 0 orderby sp.TotalScore, sp.playerName select sp).ToList(); for (int i = 0; i < sortedPlayers.Count(); i++) { sortedPlayers[i].currentPosition = i + 1; } // Get list of hole Pars for this course List <int> parList = new List <int>(); for (int i = 1; i < 19; i++) { parList.Add(cInfo.GetHolePar(i, courseID, "Yellow")); } ViewBag.ParList = parList; // Get course Name for title ViewBag.Course = cInfo.GetCourseName(courseID); ViewBag.CompID = compID; ViewBag.CourseID = courseID; // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.CourseList = courseInfo.GetCourseList(); // Return List to View return(PartialView("_EclecticLeagueTable", sortedPlayers)); }