Ejemplo n.º 1
0
 private WalletOperationResult GetOperationResult(Entities.Wallet wallet, Transaction transaction, bool isDuplicate)
 {
     return(new WalletOperationResult
     {
         Balance = wallet.Data.Balance,
         Currency = wallet.Data.CurrencyCode,
         ExternalTransactionId = transaction.TransactionNumber,
         PlatformTransactionId = transaction.Id.ToString(),
         IsDuplicate = isDuplicate
     });
 }
 public ICollection <Transaction> Resolve(AddWalletRequest source, Entities.Wallet destination, ICollection <Transaction> destMember, ResolutionContext context)
 {
     return(new[]
     {
         new Transaction()
         {
             Description = source.BaseTransaction.Description,
             Amount = source.BaseTransaction.Amount,
             RegisteredOn = source.RegisteredOn
         }
     });
 }
Ejemplo n.º 3
0
        public async Task <WalletDTO> Delete([FromBody] WalletDTO walletRequestDTO)
        {
            Entities.Wallet requestWallet = new Entities.Wallet
            {
                UserId = currentUserId,
                Name   = walletRequestDTO.Name
            };
            Entities.Wallet resultWallet = await walletService.Delete(requestWallet);

            return(new WalletDTO
            {
                Name = resultWallet.Name,
                Balance = resultWallet.Balance,
                UserId = resultWallet.UserId,
                Errors = resultWallet.Errors
            });
        }
Ejemplo n.º 4
0
        public async Task <WalletDTO> Update([FromBody] WalletUpdateRequestDTO walletUpdateRequestDTO)
        {
            Entities.Wallet requestWallet = new Entities.Wallet
            {
                UserId  = currentUserId,
                Balance = walletUpdateRequestDTO.Balance,
                Name    = walletUpdateRequestDTO.Name
            };
            Entities.Wallet resultWallet = await walletService.UpdateWalletName(requestWallet, walletUpdateRequestDTO.NewName);

            return(new WalletDTO
            {
                Name = resultWallet.Name,
                Balance = resultWallet.Balance,
                UserId = resultWallet.UserId,
                Errors = resultWallet.Errors,
            });
        }
Ejemplo n.º 5
0
        public async Task <WalletTransferResponseDTO> Transfer([FromBody] WalletTransferRequestDTO walletTransferRequestDTO)
        {
            // Tao 2 wallet BO de gui cho Service xu ly Transfer
            Entities.Wallet sourceWallet = new Entities.Wallet
            {
                Name   = walletTransferRequestDTO.SourceWalletName,
                UserId = currentUserId
            };
            Entities.Wallet destWallet = new Entities.Wallet
            {
                Name   = walletTransferRequestDTO.DestWalletName,
                UserId = currentUserId
            };
            Tuple <Entities.Wallet, Entities.Wallet> res = await walletService.Transfer(
                Tuple.Create(sourceWallet, destWallet),
                walletTransferRequestDTO.Amount,
                walletTransferRequestDTO.Note);

            // Tao response object
            WalletTransferResponseDTO resDTO = new WalletTransferResponseDTO
            {
                SourceWalletName = res.Item1.Name,
                DestWalletName   = res.Item2.Name,
                UserId           = res.Item1.UserId,
                Errors           = new List <string>()
            };

            if (res.Item1.Errors != null)
            {
                resDTO.Errors.AddRange(res.Item1.Errors);
            }
            if (res.Item2.Errors != null)
            {
                resDTO.Errors.AddRange(res.Item2.Errors);
            }
            return(resDTO);
        }