/// <summary> /// Creates a new session for the given user, /// with <paramref name="pQuestionsQuantity"/> questions from the /// given category and level. /// </summary> /// <returns>The session.</returns> /// <param name="pUserId">User identifier</param> /// <param name="pCategoryId">Category identifier.</param> /// <param name="pLevelId">Level identifier.</param> /// <param name="pQuestionsQuantity">Questions quantity.</param> public ResponseDTO <SessionDTO> NewSession(int pUserId, int pCategoryId, int pLevelId, int pQuestionsQuantity) { try { return(_sessionService.NewSession(pUserId, pCategoryId, pLevelId, pQuestionsQuantity)); } catch (Exception ex) { _logger.Error(ex, $"{ex.Message} ::" + $" Parameters: pUserId={pUserId}, pCategoryId={pCategoryId}, pLevelId={pLevelId}," + $" pQuestionsQuantity={pQuestionsQuantity}"); ResponseCode errorCode = ResponseCode.InternalError; if (ex.GetType() == typeof(NotFoundException)) { errorCode = ResponseCode.NotFound; } else if (ex.GetType() == typeof(BadRequestException)) { errorCode = ResponseCode.BadRequest; } return(ResponseDTO <SessionDTO> .Error(ErrorMessageHelper.FailedOperation("creating a new session"), errorCode)); } }