public bool Save(Categoria t) { try { context.Entry(t).State = EntityState.Added; context.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public bool Delete(Producto t) { try { context.Entry(t).State = EntityState.Deleted; context.SaveChanges(); } catch (Exception) { return(false); } return(true); }
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()); }
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()); }
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; }
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); }