public ActionResult SetupRound(int holeId) { var teeId = Convert.ToInt32(TempData["teeId"]); var tees = _context.TeeModels.FirstOrDefault(c => c.Id == teeId); var course = tees.CourseModelId; var holePar = _context.HoleModels.FirstOrDefault(c => c.Id == holeId).HolePar; var roundModel = new RoundModel { CourseModelId = course, TeeModelId = teeId, HoleModelId = holeId, }; var viewModel = new NewRoundViewModel { HoleModels = _context.HoleModels.Where(c => c.TeeModelId == teeId), RoundModel = roundModel, }; TempData["courseId"] = course; TempData["teeId"] = teeId; TempData["holeId"] = holeId; TempData["holeCount"] = 1; if (holePar == 3) { return(RedirectToAction("Green", "NewRound")); } return(RedirectToAction("Fairway", "NewRound")); }
//*********************************************************** //* FAIRWAY * //*********************************************************** public ActionResult Fairway() { var holeCount = Convert.ToInt32(TempData["holeCount"]); TempData["holeCount"] = holeCount; var courseId = Convert.ToInt32(TempData["courseId"]); TempData["courseId"] = courseId; var teeId = Convert.ToInt32(TempData["teeId"]); TempData["teeId"] = teeId; var holeId = Convert.ToInt32(TempData["holeId"]); TempData["holeId"] = holeId; var roundModel = new RoundModel { CourseModelId = courseId, TeeModelId = teeId, HoleModelId = holeId, }; var viewModel = new NewRoundViewModel { HoleModels = _context.HoleModels.Where(c => c.Id == roundModel.HoleModelId), RoundModel = roundModel, }; return(View(viewModel)); }
public ActionResult ChooseTees(int courseId) { var tees = _context.TeeModels.Where(c => c.CourseModelId == courseId); var viewModel = new NewRoundViewModel { TeeModels = tees, }; return(View(viewModel)); }
//*********************************************************** //* SETUP * //*********************************************************** public ActionResult ChooseCourse() { var courses = _context.CourseModels.ToList(); var viewModel = new NewRoundViewModel { CourseModels = courses, }; return(View(viewModel)); }
public ActionResult ChooseStartingHole(int teeId) { var holes = _context.HoleModels.Where(c => c.TeeModelId == teeId); var viewModel = new NewRoundViewModel { HoleModels = holes, }; TempData["teeId"] = teeId; return(View(viewModel)); }
//*********************************************************** //* SCORE * //*********************************************************** public ActionResult Score() { var holeCount = Convert.ToInt32(TempData["holeCount"]); TempData["holeCount"] = holeCount; var courseId = Convert.ToInt32(TempData["courseId"]); TempData["courseId"] = courseId; var teeId = Convert.ToInt32(TempData["teeId"]); TempData["teeId"] = teeId; var holeId = Convert.ToInt32(TempData["holeId"]); TempData["holeId"] = holeId; var fairway = Convert.ToInt32(TempData["fairway"]); TempData["fairway"] = fairway; var green = Convert.ToInt32(TempData["green"]); TempData["green"] = green; var putts = Convert.ToInt32(TempData["putts"]); TempData["putts"] = putts; var roundModel = new RoundModel { CourseModelId = courseId, TeeModelId = teeId, HoleModelId = holeId, }; var viewModel = new NewRoundViewModel { HoleModels = _context.HoleModels.Where(c => c.Id == roundModel.HoleModelId), RoundModel = roundModel, }; return(View(viewModel)); }