Example #1
0
 public HttpResponseMessage ConsultaDespachos()
 {
     try
     {
         var result = new HttpResponseMessage(HttpStatusCode.OK);
         List <DespachoModel> despachos = DespachoLN.ListarDespachos();
         string json = JsonConvert.SerializeObject(despachos);
         result.Content = new StringContent(json);
         result.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
         return(result);
     }
     catch (Exception e)
     {
         string error  = e.Message;
         var    result = new HttpResponseMessage(HttpStatusCode.BadRequest);
         result.Content = new StringContent("SurgiĆ³ un problema al obtener los datos");
         return(result);
     }
 }
Example #2
0
 public HttpResponseMessage Insertar(DespachoModel despacho)
 {
     try
     {
         var    respuesta = new HttpResponseMessage(HttpStatusCode.OK);
         string resultado = DespachoLN.InsertarDespacho(despacho.CodDespacho, despacho.Nombre);
         string json      = JsonConvert.SerializeObject(resultado);
         respuesta.Content = new StringContent(json);
         respuesta.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
         return(respuesta);
     }
     catch (Exception e)
     {
         string error  = e.Message;
         var    result = new HttpResponseMessage(HttpStatusCode.BadRequest);
         string json   = JsonConvert.SerializeObject("SurgiĆ³ un problema al obtener los datos");
         result.Content = new StringContent(json);
         return(result);
     }
 }