示例#1
0
        public async Task <IActionResult> Help([FromBody] HelpRequestModel helpRequestModel)
        {
            string selectedPage = helpRequestModel.SelectedPage;
            Client client       = helpRequestModel.Client;
            string result       = string.Empty;

            try
            {
                #region Error Checking
                ErrorResponse errorResponse = null;

                if (client == null && string.IsNullOrWhiteSpace(selectedPage))
                {
                    errorResponse = new ErrorResponse()
                    {
                        Message     = errorSettings.MessageNoInputs,
                        ErrorCode   = HttpStatusCode.BadRequest.ToString(),
                        Description = "No input data is passed"
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.NotFound));
                }
                #endregion
                List <ContextHelpData> contextHelpCollection = new List <ContextHelpData>();
                string[] pageNames = sharedSettings.MatterCenterPages.Split(';');
                switch (selectedPage)
                {
                case "1":
                    selectedPage = pageNames[1];
                    break;

                case "2":
                    selectedPage = pageNames[2];
                    break;

                case "4":
                    selectedPage = pageNames[4];
                    break;

                default:
                    selectedPage = pageNames[0];
                    break;
                }
                string cacheKey = string.Concat(selectedPage, ServiceConstants.LINKS_STATIC_STRING);
                result = ServiceUtility.GetDataFromAzureRedisCache(cacheKey);
                if (string.IsNullOrEmpty(result))
                {
                    contextHelpCollection = await sharedRepository.GetMatterHelpAsync(client, selectedPage);

                    ServiceUtility.SetDataIntoAzureRedisCache <List <ContextHelpData> >(cacheKey, contextHelpCollection);
                }
                else
                {
                    contextHelpCollection = JsonConvert.DeserializeObject <List <ContextHelpData> >(result);
                }
                return(matterCenterServiceFunctions.ServiceResponse(contextHelpCollection, (int)HttpStatusCode.OK));
            }
            catch (Exception exception)
            {
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }