public bool Add(T item) { try { db.Entry(item).State = EntityState.Added; db.SaveChanges(); return(true); } catch { throw; } }
public bool Update(T obj) { using (var d = new PlasticFactoryEntities()) try { DbSet dSet = d.Set <T>(); dSet.Attach(obj); d.Entry(obj).State = EntityState.Modified; d.SaveChanges(); return(true); } catch { throw; } }
public bool Delete(T item) { try { if (db.Entry(item).State == EntityState.Detached) { dbSet.Attach(item); } dbSet.Remove(item); db.SaveChanges(); return(true); } catch { return(false); } }