public ActionResult AddPrediction() { var repository = GetRepository<League>(); var league = repository.All().First(); var season = league.GetCurrentSeason(); var activeWeek = season.GetWeekSeason(SystemDate.Current()); //If out of time zone then redirect if (season.GetCurrentWeekSeason().PassedCutOff()) return Redirect("/player/tolate"); if (activeWeek.Matches.Count > 0) { var player = GetPlayer(); var predictions = player.Predictions.Where(x => activeWeek.Matches.Any(m => m.Id == x.Match.Id)); var model = new AddPredictionViewModel() { IsAdminAddingPrediction = false, OptionalMatches = activeWeek.Matches.OrderBy(y => y.MatchDate).ToArray(), CurrentPredictions = predictions, PlayerId = player.Id, WeekId = activeWeek.Id, MotW = activeWeek.MatchOfTheWeek }; return View(model); } else { return Redirect("/NotFound"); } }
public ActionResult editplayerspredictions(int playerId, int WeekId) { var season = GetRepository<League>().All().First().GetCurrentSeason(); var activeWeek = GetRepository<Week>().Get(WeekId); var player = GetRepository<Player>().Get(playerId); if (activeWeek.Matches.Count > 0) { var predictions = player.Predictions.Where(x => activeWeek.Matches.Any(m => m.Id == x.Match.Id)); var model = new AddPredictionViewModel() { IsAdminAddingPrediction = true, OptionalMatches = activeWeek.Matches.OrderBy(y => y.MatchDate).ToArray(), CurrentPredictions = predictions, PlayerId = player.Id, WeekId = activeWeek.Id, MotW = activeWeek.MatchOfTheWeek }; return View("addprediction", model); } else { return Redirect("/NotFound"); } }