public void Update(Contact contact) { using (var db = new TradeEntities()) { db.Entry(contact).State = EntityState.Modified; db.SaveChanges(); } }
public void Create(Contact contact) { using (var db = new TradeEntities()) { db.Contact.Add(contact); db.Entry(contact).State = EntityState.Added; db.SaveChanges(); } }
public void Delete(int id) { using (var db = new TradeEntities()) { var item = db.Contact.Find(id); if (item == null) { return; } db.Entry(item).State = EntityState.Deleted; db.SaveChanges(); } }