Ejemplo n.º 1
0
 public bool Save(Categoria t)
 {
     try
     {
         context.Entry(t).State = EntityState.Added;
         context.SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 2
0
 public bool Delete(Producto t)
 {
     try
     {
         context.Entry(t).State = EntityState.Deleted;
         context.SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutCliente(int id, Cliente cliente)
        {
            if (id != cliente.ClienteId)
            {
                return(BadRequest());
            }

            _context.Entry(cliente).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClienteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PutProducto(int id, Producto producto)
        {
            if (id != producto.ProductoId)
            {
                return(BadRequest());
            }

            _context.Entry(producto).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "id,Nombre,Precio")] Producto producto)
 {
     if (ModelState.IsValid)
     {
         db.Entry(producto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(producto));
 }
        public bool Registrar(Comprobante comprobante) {
            try
            {
                using (var context = new FacturadorContext())
                {
                    context.Entry(comprobante).State = EntityState.Added;
                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 7
0
        public bool Registrar(Factura factura)
        {
            try
            {
                using (var context = new FacturadorContext())
                {
                    context.Entry(factura).State = EntityState.Added;
                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }