private static bool ExecuteDB(Department Dept, DBQueryType queryType) { using (spiffaiwebEntities db = LoadDB()) { switch (queryType) { case DBQueryType.Add: db.Departments.Add(Dept); break; case DBQueryType.Update: db.Departments.Attach(Dept); db.Entry(Dept).State = System.Data.Entity.EntityState.Modified; break; case DBQueryType.Delete: db.Departments.Remove(Dept); break; default: break; } db.SaveChanges(); } return true; }
public static bool Update(Department Dept) { return ExecuteDB(Dept, DBQueryType.Update); }
public static bool Delete(Department Dept) { return ExecuteDB(Dept, DBQueryType.Delete); }
public static bool Add(Department Dept) { return ExecuteDB(Dept, DBQueryType.Add); }