public async Task <IActionResult> GetDashBoardInfoSearch(Model.Helper.LIDTypes LIDType, string LID) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting Dashboard Info GetDashBoardInfo LIDType : " + LIDType + ", LID Value: " + LID, "DashboardInfoController.cs", "GetDashBoardInfo"), CancellationToken.None); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "DashboardInfoController.cs", "GetDashBoardInfo"), CancellationToken.None); return(BadRequest(ModelState)); } try { string key = "dashboardInfo_" + "_" + LIDType + "_" + LID.ToString(); var data = _operation.RetrieveCache(key, new DashboardInfo()); if (data == null) { //since no data in cache, now get data from DB await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Before Database call of Service's method (GetDashboardSearchResultsPagination) for LIDType " + LIDType + " LID Value " + LID, "DashboardInfoController.cs", "Get"), CancellationToken.None); //call the Services for Data Retrieval from Database. var result = await _dashboardInfo.GetDashboardSearchResultsPagination(LIDType, Convert.ToInt32(LID)); await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "After Database call of Service's method (GetDashboardSearchResultsPagination) for LIDType " + LIDType + " LID Value " + LID, "DashboardInfoController.cs", "Get"), CancellationToken.None); data = result.Result; //Now add data to cache.. await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Adding into the Cache with Cache Key " + key, "DashboardInfoController.cs", "Get"), CancellationToken.None); await _operation.AddCacheAsync(key, data); } if (data == null) { var msg = this._localizer["NoDataFound"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, msg, "DashboardInfoController.cs", "Get"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.OK, msg)); } else { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Retrieved the Data from the Cache with Cache Key " + key, "DashboardInfoController.cs", "Get"), CancellationToken.None); return(Ok(data)); } } catch (Exception ex) { var msg = this._localizer?["GetDashboardInfoErrorMessage"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in GetDashBoardInfoSearch()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> Get(Model.Helper.LIDTypes LIDType, int LID) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting Memo Info Get " + LIDType + ", " + LID, "MemoInfoController.cs", "Get"), CancellationToken.None); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "MemoInfoController.cs", "Get"), CancellationToken.None); return(BadRequest(ModelState)); } try { string key = "memoList_" + LID.ToString(); var data = _operation.RetrieveCache(key, new MemoList()); if (data == null) { //since no data in cache, now get data from DB var result = await _memoInfo.GetMemoResults(LIDType, LID); data = result.Result; //Now add data to cache.. await _operation.AddCacheAsync(key, data); } if (data == null) { var msg = this._localizer["NoDataFound"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, msg, "MemoInfoController.cs", "Get"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.OK, msg)); } await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Memo Info Get Successful", "MemoInfoController.cs", "Get"), CancellationToken.None); return(Ok(data)); } catch (Exception ex) { var msg = this._localizer?["GetMemoInfoErrorMessage"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in MemoInfoGet()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }