public async Task <ListarFabricanteResult> Execute() { var fabricantes = await _fabricanteRepository.GetAll(); return(new ListarFabricanteResult { Fabricantes = _mapper.Map <IEnumerable <FabricanteModel> >(fabricantes) }); }
public ActionResult <List <Fabricante> > GetAll([FromHeader] string ibge) { try { ibge = _config.GetConnectionString(Connection.GetConnection(ibge)); string filtro = string.Empty; List <Fabricante> lista = _fabricanteRepository.GetAll(ibge, filtro); return(Ok(lista)); } catch (Exception ex) { var response = TrataErro.GetResponse(ex.Message, true); return(StatusCode((int)HttpStatusCode.InternalServerError, response)); } }
public HttpResponseMessage Get([FromUri] string[] include, [FromUri] bool indent = false) { try { var formatter = new MaxDepthJsonMediaTypeFormatter() { Indent = indent }; if (include.Length > 0) { formatter.SerializerSettings.MaxDepth = 100; //include.Max<string>(s => s.Split('.').Length * 5); formatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects; } else { formatter.SerializerSettings.MaxDepth = 1; } return(Request.CreateResponse <IQueryable <Fabricante> >(HttpStatusCode.OK, fabricanteRepository.GetAll(include).AsQueryable(), formatter)); } catch (Exception _excepcion) { log.Error(_excepcion); return(Request.CreateResponse(HttpStatusCode.InternalServerError, _excepcion)); } }