Ejemplo n.º 1
0
        // Remove: Cliente
        public async Task RemoveAsync(int id)
        {
            // Verifica se ID existe
            bool HasAny = await _context.Clientes.AnyAsync(Cliente => Cliente.IdCli == id);

            if (!HasAny)
            {
                throw new Exception("Id não existe");
            }

            try
            {
                Cliente cliente = await _context.Clientes.FindAsync(id);

                _context.Remove(cliente);
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Ejemplo n.º 2
0
        // Remove: Produto
        public async Task RemoveAsync(int id)
        {
            // Verifica se ID existe
            bool HasAny = await _context.Produtos.AnyAsync(prod => prod.IdProd == id);

            if (!HasAny)
            {
                throw new Exception("Id não existe");
            }

            try
            {
                Produto produto = await _context.Produtos.FindAsync(id);

                _context.Remove(produto);
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Ejemplo n.º 3
0
        // Remove: Vendedor
        public async Task RemoveAsync(int id)
        {
            // Verifica se ID existe
            bool HasAny = await _context.Vendedor.AnyAsync(vend => vend.IdVend == id);

            if (!HasAny)
            {
                throw new Exception("Id não existe");
            }

            try
            {
                Vendedor vendedor = await _context.Vendedor.FindAsync(id);

                _context.Remove(vendedor);
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Ejemplo n.º 4
0
        // Remove: Pagtos
        public async Task RemoveAsync(int id)
        {
            // Verifica se ID existe
            bool HasAny = await _context.FormaPagtos.AnyAsync(Pagto => Pagto.IdPagto == id);

            if (!HasAny)
            {
                throw new Exception("Id não existe");
            }

            try
            {
                FormaPagto formaPagto = await _context.FormaPagtos.FindAsync(id);

                _context.Remove(formaPagto);
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }