public Try <int> Update(dbcabEntities db, DbSet <TEntity> dbSet, TEntity toUpdate, TKey id, Action <TEntity, TEntity> updateAction) { Try <int> UpdateEntity(TEntity current, TEntity that) { updateAction(current, that); return(() => db.SaveChanges()); } return(GetById(dbSet, id) .Some(current => UpdateEntity(current, toUpdate)) .None(() => (() => 0))); }
public Try <int> Insert(dbcabEntities db, DbSet <TEntity> dbSet, TEntity e) { dbSet.Add(e); return(() => db.SaveChanges()); }