コード例 #1
0
        public async Task ExecuteAsync(AddPayPalOrderCommand message, CancellationToken token)
        {
            var studyRoom = await _studyRoomRepository.LoadAsync(message.SessionId, token);

            var v = await _payPalService.GetPaymentAsync(message.Token, token);

            var user = await _userRepository.LoadAsync(message.UserId, token);

            user.AddToken(message.Token, v.Amount, studyRoom);

            await _userRepository.UpdateAsync(user, token);
        }
コード例 #2
0
ファイル: WalletController.cs プロジェクト: Nazgaul/Spitball
        public async Task <IActionResult> BuyTokensAsync(PayPalTransactionRequest model,
                                                         [FromServices] IPayPalService payPal, CancellationToken token)
        {
            var userId = _userManager.GetLongUserId(User);
            var result = await payPal.GetPaymentAsync(model.Id, token);


            var amount = result.ReferenceId switch
            {
                "points_1" => 100,
                "points_2" => 500,
                "points_3" => 1000,
                _ => throw new ArgumentException(message: "invalid value")
            };


            var command = new TransferMoneyToPointsCommand(userId, amount, model.Id);
            await _commandBus.DispatchAsync(command, token);

            return(Ok());
        }

        #endregion
    }