Exemplo n.º 1
0
        public List <Cliente> GetClientes()
        {
            List <Cliente> result = new List <Cliente>();

            try
            {
                this.cnn = new Conexion();
                using (DataTable dt = cnn.GetTable("SELECT * FROM clientes WITH(NOLOCK) WHERE id_cliente > 0 AND estatus = 1"))
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        result.AddRange(dt.AsEnumerable().Select(x => new Cliente(x)));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(result);
        }
Exemplo n.º 2
0
        public List <Contacto> GetContactos(int id_cliente)
        {
            List <Contacto> result = new List <Contacto>();

            try
            {
                this.cnn = new Conexion();
                using (DataTable dt = cnn.GetTable(string.Format("SELECT * FROM contactos WITH(NOLOCK) WHERE id_contacto > 0 AND id_cliente = {0} AND estatus = 1", id_cliente)))
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        result.AddRange(dt.AsEnumerable().Select(x => new Contacto(x)));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(result);
        }