Esempio n. 1
0
        public bool Remove(int id)
        {
            var addressee = _context.Addressees.FirstOrDefault(e => e.Id == id);

            if (addressee == null)
            {
                throw new NotFoundException();
            }
            _context.Entry(addressee).State = EntityState.Deleted;
            return(_context.SaveChanges() > 0);
        }
        public bool Remove(int id)
        {
            var invoice = _context.Invoices.FirstOrDefault(invoiceFind => invoiceFind.Id == id);

            if (invoice == null)
            {
                throw new NotFoundException();
            }
            _context.SoldProducts.RemoveRange(invoice.SoldProducts);
            _context.Entry(invoice).State = EntityState.Deleted;
            return(_context.SaveChanges() > 0);
        }
        public int Salvar(DestinatarioEntity destinatario)
        {
            if (destinatario.Id == 0)
            {
                _context.Entry(destinatario).State = EntityState.Added;
            }
            else
            {
                _context.Entry(destinatario).State = EntityState.Modified;
            }

            _context.SaveChanges();
            return(destinatario.Id);
        }
Esempio n. 4
0
        public int Salvar(GrupoImpostos grupoImpostos)
        {
            var entity = _context.GrupoImpostos.Where(g => g.Id == grupoImpostos.Id).FirstOrDefault();

            if (grupoImpostos.Id == 0)
            {
                _context.Entry(grupoImpostos).State = EntityState.Added;
            }
            else
            {
                _context.Entry(entity).CurrentValues.SetValues(grupoImpostos);
            }
            _context.SaveChanges();

            return(grupoImpostos.Id);
        }
        public int Salvar(NotaFiscalEntity notafiscal)
        {
            using (var context = new NFeContext())
            {
                if (notafiscal.Id == 0)
                {
                    context.Entry(notafiscal).State = EntityState.Added;
                }
                else
                {
                    context.Entry(notafiscal).State = EntityState.Modified;
                }

                context.SaveChanges();
                return(notafiscal.Id);
            }
        }
 public ActionResult Put(string id, [FromBody] NFe nfe)
 {
     if (id != nfe.DocumentId)
     {
         return(BadRequest());
     }
     _context.Entry(nfe).State = EntityState.Modified;
     _context.SaveChanges();
     return(Ok());
 }
Esempio n. 7
0
        public int Salvar(ProdutoEntity produto)
        {
            if (produto.Id == 0)
            {
                _context.Entry(produto).State = EntityState.Added;
            }
            else
            {
                var local = _context.Set <ProdutoEntity>()
                            .Local
                            .FirstOrDefault(e => e.Id == produto.Id);

                _context.Entry(local).State   = EntityState.Detached;
                _context.Entry(produto).State = EntityState.Modified;
            }

            _context.SaveChanges();
            return(produto.Id);
        }
Esempio n. 8
0
 public bool Update(ShippingCompany shippingCompany)
 {
     _context.Entry(shippingCompany).State = EntityState.Modified;
     return(_context.SaveChanges() > 0);
 }
Esempio n. 9
0
 public bool Update(Issuer issuer)
 {
     _context.Entry(issuer).State = EntityState.Modified;
     return(_context.SaveChanges() > 0);
 }
Esempio n. 10
0
 public bool Update(Product product)
 {
     _context.Entry(product).State = EntityState.Modified;
     return(_context.SaveChanges() > 0);
 }