public void Eliminar() { try { ListaCompraContext context = new ListaCompraContext(); context.Entry(this).State = EntityState.Deleted; context.SaveChanges(); } catch (Exception) { throw; } }
public void Save() { try { ListaCompraContext context = new ListaCompraContext(); if (this.id > 0) { context.Entry(this).State = System.Data.Entity.EntityState.Modified; } else { context.Entry(this).State = System.Data.Entity.EntityState.Added; } context.SaveChanges(); } catch (Exception) { throw; } }