Exemple #1
0
        public async Task <ActionResult> GetQuestionsForAutocomplete(string needle)
        {
            try
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    Question[] questionList = await unitOfWork.QuestionRepository.QuestionsNamedLike(needle);

                    return(Json(AjaxActionResult.Json(questionList)));
                }
            }
            catch (Exception ex)
            {
                return(Json(AjaxActionResult.Fail(-1, "Error processing request!" + System.Environment.NewLine + ex.Message)));
            }
        }
Exemple #2
0
 public async Task <ActionResult> EntitiesNamedLike(string needle)
 {
     try
     {
         using (UnitOfWork unitOfWork = new UnitOfWork())
         {
             return(Json(
                        AjaxActionResult.Json(
                            await unitOfWork.EntityRepository.EntitiesNamedLike(needle))));
         }
     }
     catch (Exception ex)
     {
         return(Json(AjaxActionResult.Fail(-1, "Error processing request!" + System.Environment.NewLine + ex.Message)));
     }
 }
Exemple #3
0
        public async Task <JsonResult> AnswerQuestion(string gameAccessId, int answer)
        {
            try
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    await unitOfWork.GameQuestionsRepository.AnswerQuestionAndUpdateInstanceAsync(gameAccessId, (AnswerType)answer);

                    return(Json(AjaxActionResult.Json(true)));
                }
            }
            catch (Exception ex)
            {
                return(Json(AjaxActionResult.Fail(-1, "Error processing request!" + System.Environment.NewLine + ex.Message)));
            }
        }
Exemple #4
0
        public async Task <JsonResult> JudgeTopGuess(string gameAccessId, int indexGuess)
        {
            try
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    await unitOfWork.GameRepository.JudgeTopGuessAsync(gameAccessId, indexGuess);

                    return(Json(AjaxActionResult.Json(true)));
                }
            }
            catch (Exception ex)
            {
                return(Json(AjaxActionResult.Fail(-1, "Error processing request!" + System.Environment.NewLine + ex.Message)));
            }
        }
Exemple #5
0
        public async Task <JsonResult> NextQuestion(string gameAccessId)
        {
            try
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    GamePlayViewModel gamePlayVM = await unitOfWork.GameQuestionsRepository.GetGamePlayVMAsync(gameAccessId);

                    return(Json(
                               AjaxActionResult.List(
                                   this.RenderPartialView("~/Views/Game/PlayPartial/_AnsweredQuestionsPartial.cshtml", gamePlayVM.AnsweredQuestions),
                                   gamePlayVM.CurrentQuestion.QuestionBody,
                                   gamePlayVM.AnsweredQuestions.Count + 1,
                                   gamePlayVM.IsLastQuestion)));
                }
            }
            catch (Exception ex)
            {
                return(Json(AjaxActionResult.Fail(-1, "Error processing request!" + System.Environment.NewLine + ex.Message)));
            }
        }