public async Task <IActionResult> Get(int versionID, string startDate, string endDate) { try { var response = await _epsPetroAuditApi.GetEPSPetroAuditByVersion(versionID, startDate, endDate); if (response.IsSuccess) { return(Ok(response.Result)); } else { var msg = this._localizer?[response.ErrorMessages?.FirstOrDefault()?.ToString()]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, msg, "EPSPetroAuditController.cs", "Get"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.BadRequest, msg)); } } catch (Exception ex) { var msg = this._localizer?[EPSPetroAuditErrorCodes.GenericError.ToString()]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in GetEPSPetroAuditByVersion()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
/// <summary> /// validate XML file in schema and dictionary /// </summary> /// <param name="dict"></param> /// <param name="xsd"></param> /// <param name="xml"></param> /// <returns></returns> public XmlValidationMessage IsValid(string[] dictionaries, string xsd, string xml) { XmlValidationMessage message = new XmlValidationMessage(); if (string.IsNullOrEmpty(xsd) || string.IsNullOrEmpty(xml)) { message.IsValid = false; message.ErrorMessage = "Invalid xml or schema"; return(message); } try { XDocument xdocXsd = XDocument.Parse(xsd); string xsdtargetNamespace = GetTargetNameSpaceAttribute(xdocXsd); bool errors = false; string errorMessage = string.Empty; XmlSchemaSet schemas = new XmlSchemaSet(); if (dictionaries != null) { foreach (string dict in dictionaries) { XDocument xdocDist = XDocument.Parse(dict); string dictTargetNamespace = GetTargetNameSpaceAttribute(xdocDist); schemas.Add(dictTargetNamespace, XmlReader.Create(new StringReader(dict))); } } schemas.Add(xsdtargetNamespace, XmlReader.Create(new StringReader(xsd))); XDocument xdoc = XDocument.Parse(xml); xdoc.Validate(schemas, (o, e) => { errorMessage = e.Message; errors = true; }); message.ErrorMessage = errorMessage; message.IsValid = !errors; } catch (Exception e) { message.ErrorMessage = e.Message; message.IsValid = false; _loggingFacade.LogExceptionAsync(e, string.Empty, LogLevels.Error, "Error in XmlApi IsValid()", CancellationToken.None); } return(message); }
public async Task <IActionResult> Get(int versionID) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting EPS Mapping Get " + versionID, "EPSMappingController.cs", "Get"), CancellationToken.None); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "EPSMappingController.cs", "Get"), CancellationToken.None); return(BadRequest(ModelState)); } try { string key = "epsMapping_" + versionID.ToString(); var data = _operation.RetrieveCache(key, new List <Model.EPSMapping>()); if (data == null) { //since no data in cache, now get data from DB var result = await _epsmappingApi.RetrieveEPSMappingAsync(versionID); data = (List <EPSMapping>)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, "EPSMappingController.cs", "Get"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.OK, msg)); } await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "GetEPSMapping Successful", "EPSMappingController.cs", "Get"), CancellationToken.None); return(Ok(data)); } catch (Exception ex) { var msg = this._localizer?["EPSMappingRetrieveErrorMsg"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in EPSMappingGet()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> GetTerminalDetails(int termNbr) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting GetTerminalDetails " + termNbr, "TerminalDetailsController.cs", "GetTerminalDetails"), CancellationToken.None); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "TerminalDetailsController.cs", "GetTerminalDetails"), CancellationToken.None); return(BadRequest(ModelState)); } try { string key = "terminalDetails_" + termNbr.ToString(); var data = _operation.RetrieveCache(key, new EAndPData()); if (data == null) { //since no data in cache, now get data from DB var result = _terminalDetailsApi.GetTerminalDetails(termNbr); 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, "TerminalDetailsController.cs", "GetTerminalDetails"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.OK, msg)); } await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "GetTerminalDetails Successful", "TerminalDetailsController.cs", "GetTerminalDetails"), CancellationToken.None); return(Ok(data)); } catch (Exception ex) { var msg = this._localizer?["GenericError"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in GetTerminalDetails()", 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 Dashboard Info Get " + LIDType + ", " + LID, "DashboardInfoController.cs", "Get"), CancellationToken.None); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "DashboardInfoController.cs", "Get"), CancellationToken.None); return(BadRequest(ModelState)); } try { string key = "dashboardInfo_" + LID.ToString(); var data = _operation.RetrieveCache(key, new DashboardInfo()); if (data == null) { //since no data in cache, now get data from DB var result = await _dashboardInfo.GetDashboardSearchResults(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, "DashboardInfoController.cs", "Get"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.OK, msg)); } await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Dashboard Info Get Successful", "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 GetDashBoardInfoGet()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> GetBaseVersions() { try { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Web Api call for GetBaseVersions", "CommanderVersionController.cs", "GetBaseVersions"), CancellationToken.None); var response = await _commanderVersionApi.GetBaseVersions(); return(Ok(response.Result)); } catch (Exception ex) { var msg = this._localizer?["CommanderGetBaseVersionsErrorMsg"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in GetBaseVersions()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> GetTableSchema([FromBody] string schemaDef) { try { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting GetTableSchema ", "XmlController.cs", "GetTableSchema"), CancellationToken.None); TableProperty result = await Task.Run(() => _xmlApi.GetTableProperty(schemaDef)); return(Ok(result)); } catch (System.Exception ex) { await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in XmlController GetTableSchema() ", CancellationToken.None); return(BadRequest(ex)); } }
public async Task <IActionResult> GetParameters(int?parameterId = null) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting GetParameters " + parameterId ?? "", "ParametersController.cs", "GetParameters"), CancellationToken.None); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "ParametersController.cs", "GetParameters"), CancellationToken.None); return(BadRequest(ModelState)); } try { string key = "parameters_" + Convert.ToString(parameterId); var data = _operation.RetrieveCache(key, new List <Model.Parameters>()); if (data == null) { //since no data in cache, now get data from DB var result = await _parametersApi.GetParameters(parameterId); if (result.IsSuccess) { data = (List <Model.Parameters>)result.Result; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "ParametersController GetParameters Successful", "GetParametersController.cs", "GetParameters"), CancellationToken.None); //Now add data to cache.. await _operation.AddCacheAsync(key, data); } else { var msg = this._localizer?["GenericError"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, msg, "ParametersController.cs", "Get"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } } if (data == null) { var msg = this._localizer["NoDataFound"]?.Value; return(this.StatusCode((int)System.Net.HttpStatusCode.OK, msg)); } return(Ok(data)); } catch (Exception ex) { //return BadRequest(ex); var msg = this._localizer?["GenericError"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in ParametersController GetParameters( " + parameterId ?? "" + ")", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> GetRecentStatement(string merchantNbr) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting GetRecentStatement " + merchantNbr, "RecentStatementController.cs", "GetRecentStatement"), CancellationToken.None); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "RecentStatementController.cs", "GetRecentStatement"), CancellationToken.None); return(BadRequest(ModelState)); } try { string key = "recentStatement_" + merchantNbr; var data = _operation.RetrieveCache(key, new List <Model.RecentStatement>()); if (data == null) { //since no data in cache, now get data from DB var result = await _recentStatementApi.GetRecentStatementAsync(merchantNbr); if (result.Result != null && result.Result.Count > 0) { await _operation.AddCacheAsync(key, result.Result); return(Ok(result.Result)); } else { var msg = this._localizer["NoDataFound"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, msg + "GetRecentStatement Unsuccessful", "RecentStatementController.cs", "GetRecentStatement"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.OK, msg)); } } await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "GetRecentStatement Successful", "RecentStatementController.cs", "GetRecentStatement"), CancellationToken.None); return(Ok(data)); } catch (Exception ex) { var msg = this._localizer?["GenericError"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in GetRecentStatement()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> Get([FromBody] CaseHistoryInput pageinput) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { LidTypeEnum LIDType = pageinput.lidTypeEnum; string LID = pageinput.LIDValue; string ExtraId = pageinput.ExtraID; PaginationCaseHistory page = pageinput.Page; var key = _localizer["UniqueKey"] + "_" + LID; if (page.SkipRecordNumber > 0) { key = key + "_" + page.SkipRecordNumber; } var result = (await _caseHistory.GetCaseHistory(LIDType, LID, ExtraId, page)); if (result.Result != null && result.Result.TotalNumberOfRecords > 0) { await _operation.AddCacheAsync(key, result.Result); return(Ok(result.Result)); } else { var msg = this._localizer["NoDataFound"]?.Value; result.Result.ModelMessage = msg; return(Ok(result.Result)); } } catch (Exception ex) { var msg = this._localizer?["InternalServerError"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in CaseHistoryGet()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> Get(string startDate, string endDate, int?LidType, string Lid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting EPS Log Get " + startDate + ", " + endDate + "," + LidType + "," + Lid, "EPSLogController.cs", "Get"), CancellationToken.None); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "EPSLogController.cs", "Get"), CancellationToken.None); return(BadRequest(ModelState)); } try { var result = await _epslogApi.GetEPSLogAsync(startDate, endDate, LidType, Lid); if (!result.IsSuccess) { var msg = this._localizer?[result.ErrorMessages?.FirstOrDefault()?.ToString()]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, msg + "GetEPSLog Unsuccessful", "EPSLogController.cs", "Get"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.BadRequest, msg)); } if (result.Result == null) { var msg = this._localizer["NoDataFound"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, msg, "EPSLogController.cs", "Get"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.OK, msg)); } await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "GetEPSLog Successful", "EPSLogController.cs", "Get"), CancellationToken.None); return(Ok(result.Result)); } catch (Exception ex) { var msg = this._localizer?[EPSLogErrorCodes.EPSLogError.ToString()]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in EPSLogGet()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> Get(int id) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting MerchantProfileController id: " + id, "MerchantProfileController.cs", "Get"), CancellationToken.None); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "MerchantProfileController.cs", "Get"), CancellationToken.None); return(BadRequest(ModelState)); } try { //first check if the data is in cache.. var data = new Operation(_cache).RetrieveCache(id.ToString(), new MerchantProfile()); if (data == null) { //since no data in cache, now get data from DB data = await _mprofileApi.GetMerchantProfileGeneralInfoAsync(id); if (data != null) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Get MerchantProfile Successful", "MerchantProfileController.cs", "Get"), CancellationToken.None); //Now add data to cache.. await new Operation(_cache).AddCacheAsync(id.ToString(), data); } } if (data == null) { return(Ok(new string[] { "value1", "Not Found" })); } return(Ok(data)); } catch (Exception ex) { await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in MerchantProfileController Get(" + id + ")", CancellationToken.None); return(BadRequest(ex)); } }
public IEnumerable <string> Get() { _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting get Value ", "ValueController.cs", "Get"), CancellationToken.None); if (!ModelState.IsValid) { _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "ValuesController.cs", "Get"), CancellationToken.None); return(new string[] { System.Net.HttpStatusCode.InternalServerError.ToString() }); } try { var result = new string[] { "Environment Name", this._optionsAccessor?.Value?.EnvironmentName }; _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Get values Successful", "ValuesController.cs", "Get"), CancellationToken.None); return(result); } catch (Exception ex) { _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in ValuesController Get()", CancellationToken.None); string exceptionMsg = string.Format("Error,{0},{1}", ex.Message, ex.InnerException == null ? "" : ex.InnerException.Message); return(new string[] { exceptionMsg }); } }
public async Task <IActionResult> GetTerminalList([FromBody] TerminalListInput pageinput) { try { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Starting Terminal List Controller", "TerminalListController.cs", "TerminalListController_HttpPost"), CancellationToken.None); int merchantId = Convert.ToInt32(pageinput.LIDValue); PaginationTerminal page = pageinput.Page; var key = UniqueCachingKey(pageinput); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //first check if the data is in cache.. var data = _operation.RetrieveCache(key, new GenericPaginationResponse <Terminal>()); if (data == null) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Calling the Services(GetTerminalListAsync) the Terminal List for MerchantID - " + merchantId, "TerminalListController.cs", "GetTerminalList_HttpPost"), CancellationToken.None); var result = await _terminalListApi.GetTerminalListAsync(merchantId, page); if (result.ErrorMessages.Count == 0) { if (result.Result != null && result.Result.TotalNumberOfRecords > 0) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Fetched the Terminal List resultset for MerchantID - " + merchantId, "TerminalListController.cs", "GetTerminalList_HttpPost"), CancellationToken.None); await _operation.AddCacheAsync(key, result.Result); await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Added to Cache for the Terminal List resultset for MerchantID - " + merchantId, "TerminalListController.cs", "GetTerminalList_HttpPost"), CancellationToken.None); return(Ok(result.Result)); } else { var msg = this._localizer["NoDataFound"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, msg + "while Fetching the Terminal List resultset for MerchantID - " + merchantId, "TerminalListController.cs", "GetTerminalList_HttpPost"), CancellationToken.None); result.Result.ModelMessage = msg; return(Ok(result.Result)); } } else { var msg = this._localizer?["InternalServerError"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, "Error occured for MerchantID - " + merchantId + ", " + msg, "TerminalListController.cs", "GetTerminalList_HttpPost"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } } await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Fetched the Terminal List resultset from Cache key for MerchantID - " + key, "TerminalListController.cs", "GetTerminalList_HttpPost"), CancellationToken.None); return(Ok(data)); } catch (Exception ex) { var msg = this._localizer?["InternalServerError"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in GetTerminalList()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> GetContactList([FromBody] ContactListInput pageinput) { try { LidTypeEnum LIDType = pageinput.lidTypeEnum; string LID = pageinput.LIDValue; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "start calling the HttpPost method for the Contact List controller for input - " + LIDType + ", Value - " + LID, "ContactListController.cs", "GetContactList"), CancellationToken.None); PaginationDemographics page = pageinput.Page; var key = UniqueCachingKey(pageinput); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "ContactListController.cs", "GetContactList"), CancellationToken.None); return(BadRequest(ModelState)); } var data = _operation.RetrieveCache(key, new GenericPaginationResponse <Demographics>()); if (data == null) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "calling service for getting Contact List resultset from DB", "ContactListController.cs", "GetContactList"), CancellationToken.None); //since no data in cache, now get data from DB var result = await _contactList.GetContactListAsync(LIDType, LID, page); if (result.ErrorMessages.Count == 0) { if (result.Result != null && result.Result.TotalNumberOfRecords > 0) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, " Fetched the Contact List resultset", "ContactListController.cs", "GetContactList"), CancellationToken.None); //Now add data to cache.. await _operation.AddCacheAsync(key, data); return(Ok(result.Result)); } else { var msg = this._localizer["NoDataFound"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, msg + " while Fetching the Contact List resultset", "ContactListController.cs", "GetContactList"), CancellationToken.None); result.Result.ModelMessage = msg; return(Ok(result.Result)); } } else { var msg = this._localizer?["InternalServerError"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, msg, "ContactListController.cs", "GetContactList"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } } await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Fetched the Contact List resultset from Cache key - " + key, "ContactListController.cs", "GetContactList"), CancellationToken.None); return(Ok(data)); } catch (Exception ex) { var msg = this._localizer?["InternalServerError"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in GetContactList()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }
public async Task <IActionResult> GetTransactionHistory([FromBody] TransactionHistoryInput pageinput) { try { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Web Api call for Transaction History Controller " + pageinput.lidTypeEnum.ToString() + ", Value - " + pageinput.LIDValue, "TransactionHistoryController.cs", "GetTransactionHistory"), CancellationToken.None); string terminalId = pageinput.LIDValue; PaginationTransactionHistory page = pageinput.Page; var key = UniqueCachingKey(pageinput); if (!ModelState.IsValid) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, ModelState.ToString(), "TransactionHistoryController.cs", "GetTransactionHistory"), CancellationToken.None); return(BadRequest(ModelState)); } //first check if the data is in cache.. var data = _operation.RetrieveCache(key, new GenericPaginationResponse <TransactionHistory>()); if (data == null) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "calling the GetTransactionHistoryAsync for resultset(Transaction Hostory) " + pageinput.lidTypeEnum.ToString() + ", Value - " + pageinput.LIDValue, "TransactionHistoryController.cs", "GetTransactionHistory"), CancellationToken.None); var result = await _transactionHistoryApi.GetTransactionHistoryAsync(terminalId, page); if (result.ErrorMessages.Count == 0) { if (result.Result != null && result.Result.TotalNumberOfRecords > 0) { await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "got the resultset for the GetTransactionHistoryAsync " + pageinput.lidTypeEnum.ToString() + ", Value - " + pageinput.LIDValue, "TransactionHistoryController.cs", "GetTransactionHistory"), CancellationToken.None); await _operation.AddCacheAsync(key, result.Result); await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "Added to Cache for the Terminal List resultset " + pageinput.lidTypeEnum.ToString() + ", Value - " + pageinput.LIDValue, "TransactionHistoryController.cs", "GetTransactionHistory"), CancellationToken.None); return(Ok(result.Result)); } else { var msg = this._localizer["NoDataFound"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "GetTransactionHistoryAsync No Data Found " + pageinput.lidTypeEnum.ToString() + ", Value - " + pageinput.LIDValue, "TransactionHistoryController.cs", "GetTransactionHistory"), CancellationToken.None); result.Result.ModelMessage = msg; return(Ok(result.Result)); } } else { var msg = this._localizer?["InternalServerError"]?.Value; await _loggingFacade.LogAsync(new LogEntry(LogLevels.Error, "Error Occured for " + pageinput.lidTypeEnum.ToString() + ", Value - " + pageinput.LIDValue + " " + msg, "TransactionHistoryController.cs", "GetTransactionHistory"), CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } } await _loggingFacade.LogAsync(new LogEntry(LogLevels.Info, "GetTransaction History Got resultset from Cache " + key + ", Value - " + pageinput.LIDValue, "TransactionHistoryController.cs", "GetTransactionHistory"), CancellationToken.None); return(Ok(data)); } catch (Exception ex) { var msg = this._localizer?["InternalServerError"]?.Value; await _loggingFacade.LogExceptionAsync(ex, this.HttpContext?.Request?.Headers["UserName"], LogLevels.Error, "Error in GetTransactionHistory()", CancellationToken.None); return(this.StatusCode((int)System.Net.HttpStatusCode.InternalServerError, msg)); } }