public void StoreAnswerId(string questionId, string answer)
        {
            if (answer != null)
            {
                var question = _questionManager.GetQuestion(questionId);

                if (question != null)
                {
                    var validAnswers = answer.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).Where(a => question.AnswerList.Any(x => x.Id == a)).ToArray();

                    var cookie = _cookieContext.GetCookie(Constants.CookieName.Answers) ?? new HttpCookie(Constants.CookieName.Answers);
                    cookie[questionId] = validAnswers.Any() ? string.Join(",", validAnswers) : null;

                    _cookieContext.SetCookie(cookie);
                }
            }
        }
Exemplo n.º 2
0
        private void CyclePlayers()
        {
            var penguins = allObjects.Where(t => t.GetType() == typeof(SmartPenguin)).Select(p => p as SmartPenguin).ToList();

            for (int player = 1; player <= this.PlayersCount; player++)
            {
                IQuestion q = questionManager.GetQuestion();
                questionManager.PrintQuestion(q);
                string input = Console.ReadLine();
                if (q.InputForRightAnswer == input)
                {
                    penguins[player - 1].Update();
                }
                else
                {
                    UpdateRelatedEnemies(penguins[player - 1]);
                }
            }
        }
Exemplo n.º 3
0
        public virtual ActionResult Index(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var question = _questionManager.GetQuestion(id);

            if (question == null)
            {
                throw new ArgumentException(nameof(id));
            }

            if (question.QuestionNumber > _answerManager.GetAnswers().Count + 1)
            {
                return(RedirectToAction(MVC.Home.Index()));
            }

            question.Answer = _answerManager.RetrieveAnswerId(question.Id);
            return(View(question));
        }
Exemplo n.º 4
0
        public QuestionDto GetQuestion(int Id)
        {
            var question = _questionManager.GetQuestion(Id);

            return(question);
        }
Exemplo n.º 5
0
 public async Task <QuestionDto> GetQuestion([FromRoute] string id)
 {
     return(await _QuestionManager.GetQuestion(id));
 }
Exemplo n.º 6
0
        // GET api/<controller>/5
        public async Task <API.Models.Question> Get(int id)
        {
            var question = await _questionManager.GetQuestion(id).ConfigureAwait(false);

            return(_questionMapper.ToAnyEntity(question));
        }
Exemplo n.º 7
0
        public async Task <ActionResult <QuestionBinding> > GetQuestion(int UserClientID, int UserID, int DictionaryID, int QuestionTypeID)
        {
            var value = _manager.GetQuestion(UserID, UserClientID, DictionaryID, QuestionTypeID);

            return(await value);
        }