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);
            }
        }
Exemple #2
0
 public TEntity Update(TEntity entity)
 {
     entity = _repository.Update(entity);
     _cacheService.Clear();
     return(entity);
 }