public ConsultaProductosRespuesta Consultar() { ConsultaProductosRespuesta respuesta = new ConsultaProductosRespuesta(); try { conexion.Open(); respuesta.productos = repositorio.Consultar(); conexion.Close(); respuesta.Error = false; if (respuesta.productos.Count > 0) { respuesta.Mensaje = "Se consultan los Datos"; } else { respuesta.Mensaje = "No hay datos para consultar"; } respuesta.Error = false; return(respuesta); } catch (Exception e) { respuesta.Mensaje = $"Error de la Aplicacion: {e.Message}"; respuesta.Error = true; return(respuesta); } finally { conexion.Close(); } }