private void ProcceedAvailableTransactionsAsync(IInvocation invocation) { this._unitOfWorkAsync.BeginTransaction(); try { invocation.Proceed(); } catch (Exception ex) { _unitOfWorkAsync.Dispose(); throw ex; } if (invocation.Method.ReturnType == typeof(Task)) { invocation.ReturnValue = PublicAsyncHelper.AwaitTaskWithPostActionAndFinally( (Task)invocation.ReturnValue, async() => await _unitOfWorkAsync.CommitAsync(), exception => _unitOfWorkAsync.Dispose() ); } else //Task<TResult> { invocation.ReturnValue = PublicAsyncHelper.CallAwaitTaskWithPostActionAndFinallyAndGetResult( invocation.Method.ReturnType.GenericTypeArguments[0], invocation.ReturnValue, async() => await _unitOfWorkAsync.CommitAsync(), exception => _unitOfWorkAsync.Dispose() ); } }
public Task AddClaimAsync(IdentityUser user, Claim claim) { if (user == null) { throw new ArgumentNullException("user"); } if (claim == null) { throw new ArgumentNullException("claim"); } var user1 = _userRepository.FindById(user.Id); if (user1 == null) { throw new ArgumentException("IdentityUser does not correspond to a User entity.", "user"); } var claim1 = new Domain.Entities.Account.Claim { ClaimType = claim.Type, ClaimValue = claim.Value, User = user1 }; user1.Claims.Add(claim1); _userRepository.Update(user1); return(_unitOfWork.CommitAsync()); }
public Task CreateAsync(IdentityRole role) { if (role == null) { throw new ArgumentNullException("role"); } var role1 = GetRole(role); _roleRepository.Add(role1); return(_unitOfWork.CommitAsync()); }