public int Update(T entity) { using (GovernmentDbContext entityContext = new GovernmentDbContext()) { entityContext.Entry <T>(entity).State = EntityState.Modified; return(entityContext.SaveChanges()); } }
public int Remove(T entity) { using (GovernmentDbContext entityContext = new GovernmentDbContext()) { entityContext.Entry <T>(entity).State = EntityState.Deleted; return(entityContext.SaveChanges()); } }
public int Add(T entity) { int result = 0; using (GovernmentDbContext entityContext = new GovernmentDbContext()) { var obj = AddEntity(entityContext, entity); result = entityContext.SaveChanges(); } return(result); }
public T UpdatewithObj(T entity) { using (GovernmentDbContext entityContext = new GovernmentDbContext()) { entityContext.Entry <T>(entity).State = EntityState.Modified; if (entityContext.SaveChanges() > 0) { return(entity); } return(null); } }
public T AddWithGetObj(T entity) { using (GovernmentDbContext entityContext = new GovernmentDbContext()) { var obj = AddEntity(entityContext, entity); if (entityContext.SaveChanges() > 0) { return(obj); } } return(null); }