/// <summary>
 /// Register a new User.
 /// </summary>
 /// <param name="pUsername">Username.</param>
 /// <param name="pPassword">Password.</param>
 /// <param name="pConfirmPassword">Confirmed password.</param>
 public ResponseDTO <object> SignUp(string pUsername, string pPassword, string pConfirmPassword)
 {
     try
     {
         return(_userService.SignUp(pUsername, pPassword, pConfirmPassword));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Failed to sign up.");
         return(ResponseDTO.InternalError(ErrorMessageHelper.FailedOperation("signing up")));
     }
 }
 /// <summary>
 /// Updates the questions set data.
 /// </summary>
 /// <returns>The questions set data.</returns>
 /// <param name="pQuestionsSetName">Questions set name.</param>
 public ResponseDTO <object> UpdateQuestionsSetData(string pQuestionsSetName)
 {
     try
     {
         return(_questionsSetService.UpdateQuestionsSetData(pQuestionsSetName));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Failed to update Questions Set data.");
         return(ResponseDTO.InternalError(ErrorMessageHelper.FailedOperation("updating questions set data")));
     }
 }
 /// <summary>
 /// Show ranking of session results for a given Questions Set.
 /// </summary>
 /// <param name="pQuestionsSetId">Questions set identifier.</param>
 public ResponseDTO <IEnumerable <SessionResultDTO> > ShowRanking(int pQuestionsSetId)
 {
     try
     {
         return(_sessionService.GetSessionResults(pQuestionsSetId));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Failed to fetch Session results.");
         return(ResponseDTO <IEnumerable <SessionResultDTO> > .InternalError(
                    ErrorMessageHelper.FailedOperation("fetching ranking")));
     }
 }
 /// <summary>
 /// Record an answer for a question from an ongoing session.
 /// </summary>
 /// <returns>Answer result.</returns>
 /// <param name="pSessionAnswer">Session answer parameters.</param>
 public ResponseDTO <AnswerResultDTO> AddAnswer(SessionAnswerDTO pSessionAnswer)
 {
     try
     {
         return(_sessionService.AddAnswer(pSessionAnswer));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Failed to add answer to the given session.");
         return(ResponseDTO <AnswerResultDTO> .InternalError(
                    ErrorMessageHelper.FailedOperation("recording your answer")));
     }
 }
 /// <summary>
 /// Login for the given username and password.
 /// </summary>
 /// <returns>The authorized user if login is successful.</returns>
 /// <param name="pUsername">Username.</param>
 /// <param name="pPassword">Password.</param>
 public ResponseDTO <UserDTO> Login(string pUsername, string pPassword)
 {
     try
     {
         return(_userService.Login(pUsername, pPassword));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Failed to Login.");
         return(ResponseDTO <UserDTO> .InternalError(
                    ErrorMessageHelper.FailedOperation("logging in")));
     }
 }
 /// <summary>
 /// Finish the given session and calculate its score.
 /// </summary>
 /// <param name="pSessionId">Session identifier</param>
 /// <returns>The session result <see cref="SessionResultDTO"/>.</returns>
 public ResponseDTO <SessionResultDTO> FinishSession(int pSessionId)
 {
     try
     {
         return(_sessionService.FinishSession(pSessionId));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Failed to finish Session.");
         return(ResponseDTO <SessionResultDTO> .InternalError(
                    ErrorMessageHelper.FailedOperation("attempting to finish the current session")));
     }
 }
 /// <summary>
 /// Save the specified pQuestionsSet.
 /// </summary>
 /// <param name="pQuestionsSet">Questions set DTO.</param>
 public ResponseDTO <object> SaveQuestionsSet(QuestionsSetDTO pQuestionsSet)
 {
     try
     {
         QuestionsSet modifiedQuestionsSet = _mapper.Map <QuestionsSet>(pQuestionsSet);
         return(_questionsSetService.Save(modifiedQuestionsSet));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, $"Failed to save QuestionsSet. {ex.Message}");
         return(ResponseDTO.InternalError(ErrorMessageHelper.FailedOperation("saving questions set")));
     }
 }
 /// <summary>
 /// Gets all Questions Sets available.
 /// </summary>
 /// <returns>Questions set list.</returns>
 public ResponseDTO <IEnumerable <QuestionsSetDTO> > GetQuestionsSets()
 {
     try
     {
         return(_questionsSetService.GetQuestionsSets());
     }
     catch (NoContentException)
     {
         return(ResponseDTO <IEnumerable <QuestionsSetDTO> > .NoContent("No questions sets were found."));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Failed to fetch QuestionsSet list.");
         return(ResponseDTO <IEnumerable <QuestionsSetDTO> > .InternalError(
                    ErrorMessageHelper.FailedOperation("fetching Questions Sets available")));
     }
 }