コード例 #1
0
        public ResultGeneric <PostTransfersResponse> Transfer(PostTransferAccountRequest request)
        {
            var result = new ResultGeneric <PostTransfersResponse>();

            result.Success = false;

            if (!accountServiceRepository.GetAccountHasBlocked(request.AccountIDfrom))
            {
                if (!accountServiceRepository.GetAccountHasBlocked(request.AccountIDto))
                {
                    if (GetHasBalance(request.AccountIDfrom, request.value))
                    {
                        #region AccountFrom
                        var accountTransferFrom = TransferConverter.Parse(request);
                        accountTransferFrom.TypeTransaction = Domain.Enums.ETypeTransaction.Debit;
                        accountTransferFrom.TypePay         = Domain.Enums.ETypePay.Bank;

                        transferRepository.Insert(accountTransferFrom);
                        this.Withdraw(request.AccountIDfrom, request.value);
                        #endregion

                        #region AccountTo
                        var accountTransferTo = TransferConverter.Parse(request);
                        accountTransferTo.TypeTransaction = Domain.Enums.ETypeTransaction.Credit;
                        accountTransferTo.TypePay         = Domain.Enums.ETypePay.Bank;


                        transferRepository.Insert(accountTransferTo);
                        this.Deposit(request.AccountIDto, request.value);

                        #endregion
                        result.Data = TransferConverter.Parse(accountTransferFrom);

                        result.Success = true;
                    }
                    else
                    {
                        result.Errors.Add("Conta de origem não possui saldo sulficiente");
                    }
                }
                else
                {
                    result.Errors.Add("Conta de destino está bloqueada, solicite o desbloquei se possivel!");
                }
            }
            else
            {
                result.Errors.Add("Conta de origem está bloqueada, solicite o desbloquei se possivel!");
            }

            return(result);
        }
コード例 #2
0
        public ResultGeneric <PostTransfersResponse> DepositAccount(Guid accountID, decimal value)
        {
            var result = new ResultGeneric <PostTransfersResponse>();

            if (!accountServiceRepository.GetAccountHasBlocked(accountID))
            {
                var accountTransferTo = TransferConverter.Parse(accountID, value);
                accountTransferTo.TypeTransaction = Domain.Enums.ETypeTransaction.Credit;
                accountTransferTo.TypePay         = Domain.Enums.ETypePay.Money;

                transferRepository.Insert(accountTransferTo);
                this.Deposit(accountID, value);

                result.Data    = TransferConverter.Parse(accountTransferTo);
                result.Success = true;
            }
            else
            {
                result.Errors.Add("Conta de destino está bloqueada, solicite o desbloquei se possivel!");
            }

            return(result);
        }