public IEnumerable <dynamic> Get(string resource, int userId, [FromUri] object[] resourceIds) { try { var repository = new FlagRepository(this.MetaUser.Tenant, this.MetaUser.LoginId, this.MetaUser.UserId); return(repository.Get(resource, userId, resourceIds)); } catch (UnauthorizedException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); } catch (DataAccessException ex) { throw new HttpResponseException(new HttpResponseMessage { Content = new StringContent(ex.Message), StatusCode = HttpStatusCode.InternalServerError }); } #if !DEBUG catch { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } #endif }
public void SaveGameHistory(int indexQuestion, int idAnswer, Flag correctAnswer, bool correct) { var quizResult = (TempData["QuizResult"] as List <QuestionResult>) ?? new List <QuestionResult>(); //prevents multiple answers to the same question, and prevents cheating if (quizResult.All(x => x.Index != indexQuestion)) { quizResult.Add( new QuestionResult() { Index = indexQuestion, Answer = _flagRepository.Get(idAnswer), CorrectAnswer = correctAnswer, Correct = correct, }); } TempData["QuizResult"] = quizResult; }