public static TEntity AddOrUpdate <TEntity, TTransaction>(this IHasTransactionRepository <TEntity, TTransaction> repository, TEntity entity) where TEntity : class, IStateAware where TTransaction : ITransaction { using (var tran = repository.GetTransaction()) { if (entity.IsNew) { entity = repository.Add(entity); } else { entity = repository.Update(entity); } tran.CommitIfOwner(); return(entity); } }
public TEntity Update(TEntity entity) { entity = _repository.Update(entity); _cacheService.Clear(); return(entity); }