2023-02-21

Search using iteration

Good day,

I have a problem, I'm doing a search and the result is brought to me in a JSON list using postman.

My code is the following:

[HttpGet("{nombre}")]
    public async Task<ActionResult<FichaViewModel>> GetTramite(string nombre)
    {
        string url = _configuration["UrlApiDocumentos"];
        int usuarioId = AutenticacionHelper.GetUsuario(HttpContext);
        var objUsr = await _context.master_usuarios.Where(c => c.AutenticacioId == usuarioId && c.usuIdStatusCatalogo == 797).Include(c => c.master_dependencias).FirstOrDefaultAsync();
        if (objUsr == null)
            return Unauthorized();

        var filter = _context.tra_tramites.Where(c => c.traNombre.Contains(EF.Functions.Contains(c.traNombre, "COLLATE Latin1_general_CI_AI").ToString()));

        //Traer lista
         List<string> palabras = new List<string>();
        foreach (var item in palabras)
        {
           palabras.Add(FichaHelper.GetFicha(_context, nombre, url + "Fileuploads/");
        }


        return await FichaHelper.GetFicha(_context, nombre, url + "Fileuploads/");
    }

In my string of type name, it brings me the word that I enter to search for and within my foreach I am iterating, so that it brings me the results or objects found within the list.

However, I no longer know how to implement it or what elements to add.

For which I would greatly appreciate comments and/or links, etc.

Thank you.



No comments:

Post a Comment