public async Task <GetWithdrawalsViewModel> Handle(GetWithdrawalsRequest request, CancellationToken cancellationToken) { var withdrawals = await _withdrawalRepository.GetAllAsync(); var withdrawalModels = _mapper.Map <List <WithdrawalModel> >(withdrawals); return(new GetWithdrawalsViewModel { WithdrawalsTotalCount = withdrawalModels.Count, Withdrawals = withdrawalModels }); }
public async Task <UserAccountDataModel> Handle(GetUserRequest request, CancellationToken cancellationToken = default(CancellationToken)) { ValidateRequest(request); var user = await _userAccountDataRepository.GetAsync(request.UserId); var userModel = _mapper.Map <UserAccountDataModel>(user); // More details for the home page var userWithdrawals = await _withdrawalRepository.GetAllAsync(user.UserMultiAccounts.Select(x => x.Id)); var accountsWhereRequestedUserIsSponsor = await _multiAccountHelper.GetAllWhereMultiAccountsAreSponsors(user.UserMultiAccounts.Select(x => x.Id)); userModel.EarnedBtc = userWithdrawals.Sum(x => x.Amount); userModel.InvitedAccountsTotalCount = accountsWhereRequestedUserIsSponsor.Count; userModel.AccountsInMatrixTotalCount = user.UserMultiAccounts.Count(x => x.RefLink != null); return(userModel); }