Пример #1
0
        public async Task <IActionResult> GetListSources()
        {
            try
            {
                IQueryCollection queryParams = Request.Query;

                if (queryParams.Count > 0)
                {
                    if (!AppUtils.IsValidParameters(queryParams, sourcesValidParams))
                    {
                        return(BadRequest(new Error()
                        {
                            Message = $"A consulta contém parâmetros inválidos. Parâmetros válidos: {string.Join(", ", sourcesValidParams)}", Status = "error"
                        }));
                    }
                }

                List <KeyValuePair <string, object> > parameters = AppUtils.GetParameters(queryParams, sourcesValidParams);

                var result = await _services.GetListSources(parameters);


                //var t = result.Sources.Select(c => new { name = c.Name});

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(new Error()
                {
                    Message = $"Erro ao retornar os dados. {ex.Message}", Status = "error"
                }));
            }
        }