Beispiel #1
0
 public ActionResult ShowPredictions(EditPredictionsViewModel viewModel)
 {
     return(RedirectToAction(
                "EditPredictions",
                new
     {
         tourId = viewModel.TourDto.TourId,
         expertId = viewModel.SelectedExpertId
     }));
 }
Beispiel #2
0
        public ActionResult EditPredictions(int tourId, int expertId = 1, bool addPredictionSuccess = false)
        {
            var experts = _expertService.GetExperts();
            var tourDto = _tourService.GetTourDto(tourId);
            //var matches = _matchService.GetLastTournamentMatchesByTourId(tourId).ToList();
            var matches   = _matchService.GetTourSchedule(tourId);
            var scorelist = _predictionService.GeneratePredictionlist(tourId, expertId, true);
            var viewModel = new EditPredictionsViewModel(matches, experts, scorelist, tourDto, expertId, addPredictionSuccess);

            return(View(viewModel));
        }
Beispiel #3
0
        public ActionResult EditPredictions(EditPredictionsViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            _predictionService.AddExpertPredictions(
                viewModel.SelectedExpertId,
                viewModel.TourDto.TourId,
                viewModel.MatchTable.Scorelist.Select(s => s.Score).ToList(),
                null,
                _tourService.IsPlayoff(viewModel.TourDto.TourId));
            return(RedirectToAction(
                       "EditPredictions",
                       new
            {
                tourId = viewModel.TourDto.TourId,
                expertId = viewModel.SelectedExpertId
            }));
        }
Beispiel #4
0
        public ActionResult AddPredictions(EditPredictionsViewModel viewModel)
        {
            var teamlist  = _teamService.GenerateOrderedTeamTitlelist(viewModel.SubmitTextArea.TourId);
            var scorelist = _fileService.ParseExpertPredictions(viewModel.SubmitTextArea.InputText, teamlist);

            if (!scorelist.IsNullOrEmpty())
            {
                _predictionService.AddExpertPredictions(viewModel.SelectedExpertId,
                                                        viewModel.SubmitTextArea.TourId,
                                                        scorelist.Select(s => s.Score).ToList(),
                                                        scorelist.Select(s => s.PlayoffWinner).ToList(),
                                                        _tourService.IsPlayoff(viewModel.SubmitTextArea.TourId));
            }

            return(RedirectToAction(
                       "EditPredictions",
                       new
            {
                tourId = viewModel.SubmitTextArea.TourId,
                expertId = viewModel.SelectedExpertId,
                addPredictionSuccess = !scorelist.IsNullOrEmpty()
            }));
        }