public T Edit <T>(T entity) where T : class { using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options)) { context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); return(entity); } }
public bool EditAll <T>(List <T> entityList) where T : class { using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options)) { try { foreach (var entity in entityList) { context.Entry(entity).State = EntityState.Modified; } context.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }