Exemple #1
0
        public Venda Pegar(int id)
        {
            Venda venda;

            using (var contexto = new LojaContext())
            {
                venda = (from v in contexto.Vendas.ToList <Venda>() where v.IdVenda == id select v).FirstOrDefault();
            }
            return(venda);
        }
        public ICollection <Cliente> PegarLista()
        {
            List <Cliente> lista;

            using (var contexto = new LojaContext())
            {
                lista = contexto.Clientes.ToList();
            }
            return(lista);
        }
Exemple #3
0
        public Categoria Pegar(int id)
        {
            Categoria categoria;

            using (var contexto = new LojaContext())
            {
                categoria = (from c in contexto.Categorias.ToList <Categoria>() where c.IdCategoria == id select c).FirstOrDefault();
            }
            return(categoria);
        }
Exemple #4
0
        public ICollection <Vendedor> PegarLista()
        {
            List <Vendedor> lista;

            using (var contexto = new LojaContext())
            {
                lista = contexto.Vendedores.ToList <Vendedor>();
            }
            return(lista);
        }
        public Cliente Pegar(int id)
        {
            Cliente cliente;

            using (var contexto = new LojaContext())
            {
                cliente = (from c in contexto.Clientes.ToList <Cliente>() where c.IdCliente == id select c).First();
            }

            return(cliente);
        }
Exemple #6
0
 public void Remover(int id)
 {
     using (var contexto = new LojaContext())
     {
         List <Vendedor> lista    = contexto.Vendedores.ToList <Vendedor>();
         Vendedor        vendedor = (from v in lista where v.IdVendedor == id select v).First();
         contexto.Vendedores.Attach(vendedor);
         contexto.Entry(vendedor).State = EntityState.Deleted;
         contexto.SaveChanges();
     }
 }
Exemple #7
0
        public ProdutoVenda Pegar(int id)
        {
            ProdutoVenda produto;

            using (var contexto = new LojaContext())
            {
                produto = (from p in contexto.ProdutosVenda.ToList() where p.IdProduto == id select p).First();
            }

            return(produto);
        }
        public Cliente Pegar(string cpf)
        {
            Cliente cliente;

            using (var contexto = new LojaContext())
            {
                cliente = (from c in contexto.Clientes.ToList <Cliente>() where c.Cpf == cpf select c).First();
            }

            return(cliente);
        }
Exemple #9
0
        public Vendedor Pegar(string cpf)
        {
            Vendedor vendedor;

            using (var contexto = new LojaContext())
            {
                List <Vendedor> lista = contexto.Vendedores.ToList <Vendedor>();
                vendedor = (from v in lista where v.Cpf == cpf select v).First();
            }

            return(vendedor);
        }
Exemple #10
0
        public Vendedor Pegar(int id)
        {
            Vendedor vendedor;

            using (var contexto = new LojaContext())
            {
                List <Vendedor> lista = contexto.Vendedores.ToList <Vendedor>();
                vendedor = (from v in lista where v.IdVendedor == id select v).First();
            }

            return(vendedor);
        }
        public void Remover(int id)
        {
            Cliente cliente;

            using (var contexto = new LojaContext())
            {
                cliente = (from c in contexto.Clientes.ToList <Cliente>() where c.IdCliente == id select c).First();
                contexto.Clientes.Attach(cliente);
                contexto.Entry(cliente).State = EntityState.Deleted;
                contexto.SaveChanges();
            }
        }
Exemple #12
0
        public void Remover(int id)
        {
            Produto produto;

            using (var contexto = new LojaContext())
            {
                produto = (from p in contexto.Produtos.ToList() where p.IdProduto == id select p).First();
                contexto.Produtos.Attach(produto);
                contexto.Entry(produto).State = EntityState.Deleted;
                contexto.SaveChanges();
            }
        }
Exemple #13
0
        public Produto Pegar(int id)
        {
            Produto produto;

            using (var contexto = new LojaContext())
            {
                produto           = (from p in contexto.Produtos.ToList() where p.IdProduto == id select p).First();
                produto.Categoria = contexto.Categorias.Find(produto.IdCategoria);
            }

            return(produto);
        }
Exemple #14
0
        public ICollection <Produto> PegarLista()
        {
            List <Produto> lista;

            using (var contexto = new LojaContext())
            {
                lista = contexto.Produtos.ToList();
                foreach (Produto p in lista)
                {
                    p.Categoria = contexto.Categorias.Find(p.IdCategoria);
                }
            }
            return(lista);
        }
Exemple #15
0
        public ICollection <ProdutoVenda> PegarLista()
        {
            List <ProdutoVenda> lista;

            using (var contexto = new LojaContext())
            {
                lista = contexto.ProdutosVenda.ToList();
                foreach (ProdutoVenda pv in lista)
                {
                    pv.Produto           = contexto.Produtos.Find(pv.IdProduto);
                    pv.Produto.Categoria = contexto.Categorias.Find(pv.Produto.IdCategoria);
                }
            }
            return(lista);
        }
Exemple #16
0
        public ICollection <Venda> PegarLista()
        {
            List <Venda> lista;

            using (var contexto = new LojaContext())
            {
                lista = contexto.Vendas.ToList();
                foreach (Venda v in lista)
                {
                    v.Vendedor = contexto.Vendedores.Find(v.IdVendedor);
                    v.Cliente  = contexto.Clientes.Find(v.IdCliente);
                }
            }
            return(lista);
        }
Exemple #17
0
        public void Alterar(Vendedor vendedor)
        {
            Vendedor vendedorAAlterar;

            using (var contexto = new LojaContext())
            {
                List <Vendedor> lista = contexto.Vendedores.ToList <Vendedor>();
                vendedorAAlterar = (from v in lista where v.IdVendedor == vendedor.IdVendedor select v).First();

                vendedorAAlterar.Nome = vendedor.Nome;
                vendedorAAlterar.Cpf  = vendedor.Cpf;


                contexto.SaveChanges();
            }
        }
        public void Alterar(Cliente cliente)
        {
            Cliente clienteAAlterar;

            using (var contexto = new LojaContext())
            {
                List <Cliente> lista = contexto.Clientes.ToList <Cliente>();
                clienteAAlterar = (from c in lista where c.IdCliente == cliente.IdCliente select c).First();

                clienteAAlterar.Nome = cliente.Nome;
                clienteAAlterar.Cpf  = cliente.Cpf;


                contexto.SaveChanges();
            }
        }