Example #1
0
        /// <summary>
        ///  Get list of queries based on the userId
        /// </summary>
        /// <param name="queryBuilderRequest"></param>
        /// <param name="context"></param>
        /// <returns>QueryResponse</returns>
        public QueryResponse GetQueries(QueryBuilderRequest queryBuilderRequest, ILambdaContext context = null)
        {
            QueryRepository queryRepository = new QueryRepository();
            QueryResponse   queryResponse   = new QueryResponse();
            Authorizer      authorizer      = new Authorizer();

            try
            {
                if (authorizer.ValidateUser(queryBuilderRequest.UserId, queryBuilderRequest.CompanyId))
                {
                    return(queryRepository.GetUserQueries(queryBuilderRequest));
                }
                else
                {
                    queryResponse.Error = ResponseBuilder.Forbidden();
                    return(queryResponse);
                }
            }
            catch (Exception getQueriesException)
            {
                LambdaLogger.Log(getQueriesException.ToString());
                queryResponse.Error = ResponseBuilder.InternalError();
                return(queryResponse);
            }
        }