Exemplo n.º 1
0
        public ActionResult AddPrediction(int PlayerId, int WeekId, AddPredictionInputs inputs)
        {
            try
            {
                var player = GetRepository<Player>().Get(PlayerId);
                var week = GetRepository<Week>().Get(WeekId);
                var League = GetRepository<League>().All().First();

                Match selectedMatch = week.FindMatch(inputs.MatchId);

                PlayerPrediction playerPrediction = player.CreatePrediction(selectedMatch, SystemDate.Current());

                League.AddPrediction(week, BensBoxing.Web.Core.Helpers.ControllerHelpers.SetPrediction(inputs, playerPrediction));
                var response = new AddPredictionResult
                {
                    MatchId = inputs.MatchId,
                    Success = true,
                    SummaryText = playerPrediction.ToTextSummary()
                };

                return Json(response);
            }
            catch (Exception ex)
            {
                var response = new AddPredictionResult
                {
                    MatchId = inputs.MatchId,
                    Success = false,
                    SummaryText = "N/A"
                };

                return Json(response);
            }
        }
        public ActionResult AddPrediction(AddPredictionInputs inputs)
        {
            try
            {
                var player = GetPlayer();

                var season = GetActiveSeason();
                var week = season.GetWeekSeason(SystemDate.Current());
                Match selectedMatch = week.FindMatch(inputs.MatchId);

                PlayerPrediction playerPrediction = player.CreatePrediction(selectedMatch, SystemDate.Current());

                GetLeague().AddPrediction(week, BensBoxing.Web.Core.Helpers.ControllerHelpers.SetPrediction(inputs, playerPrediction));
                DataSession.Save(playerPrediction);

                var response = new AddPredictionResult
                {
                    MatchId = inputs.MatchId,
                    Success = true,
                    SummaryText = playerPrediction.ToTextSummary()
                };

                return Json(response);
            }
            catch (Exception ex)
            {
                var response = new AddPredictionResult
                {
                    MatchId = inputs.MatchId,
                    Success = false,
                    SummaryText = "N/A"
                };

                return Json(response);
            }
        }