private async Task <Result> Validate(BaseAssignmentDto assignUserToWalletDto, string modifierId) { var userToAdd = await _userManager.GetByAsync(x => x.Id == assignUserToWalletDto.UserId); if (userToAdd == null) { return(Result.Failure()); } var userWalletOfModifier = await _walletRepository.GetWithoutDependencies(assignUserToWalletDto.WalletId.ToDeobfuscated(), modifierId); if (userWalletOfModifier == null || !userWalletOfModifier.Role.HasAllPrivileges()) { return(Result.Failure()); } return(Result.Success()); }
public void SendAssignmentEmail(BaseAssignmentDto assignUserToWalletDto, bool assigment, string modifierId, string walletName) { Task.Run(async() => { var to = await _userManager.GetByAsync(x => x.Id == assignUserToWalletDto.UserId); var modifier = await _userManager.GetByAsync(x => x.Id == modifierId); var by = $"{modifier.FirstName} {modifier.LastName}"; var message = new AssignToWalletMessage { To = to.Email, Subject = assigment ? $"{by} shared a wallet with you" : $"{by} unassigned you from wallet {walletName}", By = by, Link = $"{_clientOptions.WalletUrl}/{assignUserToWalletDto.WalletId}" }; _emailDispatcher.Dispatch(assigment ? message : GetUnnassignMessage(message, walletName)); }); }