protected async Task <IActionResult> SearchTable([FromBody] TReportsSearchTableRequest request) { Log.Information("***Executando método 'SearchTable'***"); Log.Information(JsonConvert.SerializeObject(request)); Log.Information(System.Environment.NewLine); Log.Information("-----Fim do método da leitura dos parâmetros -----" + System.Environment.NewLine); try { TReportsSearchTableResponse response = new TReportsSearchTableResponse(); response.SearchTables = new System.Collections.Generic.List <SearchTable>(); List <SearchTable> tables = new List <SearchTable>(); SearchTable pais = new SearchTable(); pais.TableSourceName = "PAIS"; pais.TableSourceDescription = "País"; tables.Add(pais); SearchTable empresa = new SearchTable(); empresa.TableSourceName = "EMPRESA"; empresa.TableSourceDescription = "Empresa"; tables.Add(empresa); SearchTable filial = new SearchTable(); filial.TableSourceName = "FILIAL"; filial.TableSourceDescription = "Filial"; tables.Add(filial); response.SearchTables = tables.FindAll(x => x.TableSourceName.ToUpper().Contains(request.FindTable.ToUpper())); return(Ok(response)); } catch (Exception ex) { Log.Error(ex.Message); Response.StatusCode = 500; return(Accepted(new TReportsCustomError() { code = "500", detailedMessage = ex.StackTrace, message = ex.Message })); } }
public IActionResult SearchTable([FromBody] TReportsSearchTableRequest request) { Log.Information("***Executando método 'SearchTable'***"); Log.Information(JsonConvert.SerializeObject(request)); Log.Information(System.Environment.NewLine); Log.Information("-----Fim do método da leitura dos parâmetros -----" + System.Environment.NewLine); try { TReportsSearchTableResponse response = new TReportsSearchTableResponse(); response.SearchTables = new System.Collections.Generic.List <SearchTable>(); List <SearchTable> tables = new List <SearchTable>(); foreach (IEntityType entityType in Context.Model.GetEntityTypes().Where(x => x.Name.Contains(request.FindTable ?? string.Empty))) { tables.Add(new SearchTable { TableSourceName = GetEntityName(entityType) }); } response.SearchTables = tables; return(Ok(response)); } catch (Exception ex) { Log.Error(ex.Message); Response.StatusCode = 500; return(Accepted(new TReportsCustomError() { code = "500", detailedMessage = ex.StackTrace, message = ex.Message })); } }