private void btnBuscar_Click(object sender, EventArgs e) { string nroCaja = txtNroCaja.Text; List <Caja> cajas = new List <Caja>(); if (string.IsNullOrEmpty(nroCaja)) { cajas = _cajaService.getAll(); } else { int id_caja = 0; if (int.TryParse(nroCaja, out id_caja)) { Caja caja = _cajaService.getById(id_caja); if (caja != null) { cajas.Add(caja); } } } if (cajas.Count > 0) { grdCajas.DataSource = cajas; } }
// GET api/Caja public HttpResponseMessage Get() { HttpResponseMessage response; try { CajaService service = (CajaService) new CajaService().setDatabase(db); List <Caja> caja = service.getAll(); response = this.getSuccessResponse(caja); } catch (Exception e) { response = this.getErrorResponse(e); } return(response); }