コード例 #1
0
        public async Task <ListarFabricanteResult> Execute()
        {
            var fabricantes = await _fabricanteRepository.GetAll();

            return(new ListarFabricanteResult {
                Fabricantes = _mapper.Map <IEnumerable <FabricanteModel> >(fabricantes)
            });
        }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
 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));
     }
 }