public ActionResult Guess(int id)
        {
            var                    ggame  = new GuessRepository().get(id);
            var                    gtopic = new GuessRepository().topicgetAll();
            GuessViewModel         gvm    = new GuessViewModel();
            List <GuessTopicModel> gtm    = new List <GuessTopicModel>();

            gvm.gs = ggame;
            foreach (var gt in gtopic)
            {
                GuessTopicModel tm = new GuessTopicModel();
                tm.title = gt.title;
                List <GuessChoiceModel> gcm = new List <GuessChoiceModel>();
                var gchoice = new GuessRepository().guessCAll(gt.id);
                foreach (var c in gchoice)
                {
                    GuessChoiceModel gc = new GuessChoiceModel();
                    gc.choiceStr = c.choiceStr;
                    gc.isTrue    = c.isTrue;
                    gcm.Add(gc);
                }
                tm.gchoice = gcm;


                gtm.Add(tm);
            }
            gtm.Shuffle();

            gvm.gtopics = gtm;
            return(View(gvm));
        }
Beispiel #2
0
 public AnswerService(AnswerRepository answerRepository, QuestionRepository questionRepository, GuessRepository guessRepository, GameStatusService gameStatusService)
 {
     this.answerRepository   = answerRepository;
     this.questionRepository = questionRepository;
     this.guessRepository    = guessRepository;
     this.gameStatusService  = gameStatusService;
 }
        public HttpResponseMessage MakeGuess(string sessionKey, [FromBody] GuessModel guess)
        {
            var response = this.PerformOperation(() =>
            {
                var userId = UsersRepository.LoginUser(sessionKey);
                GuessRepository.MakeGuess(userId, guess);
            });

            return(response);
        }