Ejemplo n.º 1
0
        /// <summary>
        /// Get query results based on the entity
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="query"></param>
        /// <param name="queryJson"></param>
        /// <returns>QueryModel</returns>
        public QueryModel GetResults(int companyId, string query, string queryJson)
        {
            QueryModel queryModel = new QueryModel();

            try
            {
                //Deserialize the query Json to get the results
                QueryBuilderRequest         queryBuilderRequest = JsonConvert.DeserializeObject <QueryBuilderRequest>(queryJson);
                Dictionary <string, string> parameterList       = ParameterHelper.Getparameters(queryBuilderRequest);
                switch (queryBuilderRequest.EntityName.ToUpper())
                {
                case Constants.TASK:
                    TaskRepository   taskRepository = new TaskRepository();
                    List <TaskModel> taskList       = taskRepository.ReadTaskDetails(query, parameterList, queryBuilderRequest);
                    queryModel.Tasks = taskList;
                    break;

                case Constants.WORKBOOK:
                    WorkbookRepository   workbookRepository = new WorkbookRepository();
                    List <WorkbookModel> workbookList       = workbookRepository.ReadWorkBookDetails(query, parameterList);
                    queryModel.Workbooks = workbookList;
                    break;

                case Constants.EMPLOYEE:
                    EmployeeRepository        employeeRepository = new EmployeeRepository();
                    List <EmployeeQueryModel> employeeList       = employeeRepository.ReadEmployeeDetails(query, parameterList);
                    queryModel.Employee = employeeList;
                    break;

                default:
                    break;
                }
                return(queryModel);
            }
            catch (Exception getResultsexception)
            {
                LambdaLogger.Log(getResultsexception.ToString());
                return(queryModel);
            }
        }