Пример #1
0
        private static Withdrawal CheckBankNotes(WithdrawalRequest withdrawalRequest)
        {
            var withdrawal       = new Withdrawal();
            var withdrawalAmount = withdrawalRequest.Amount;

            while (withdrawalAmount >= BankNotes[2])
            {
                withdrawalAmount -= BankNotes[2];
                withdrawal.FiftyReaisAmount++;
            }
            while (withdrawalAmount >= BankNotes[1])
            {
                withdrawalAmount -= BankNotes[1];
                withdrawal.TwentyReaisAmount++;
            }
            while (withdrawalAmount >= BankNotes[0])
            {
                withdrawalAmount -= BankNotes[0];
                withdrawal.TenReaisAmount++;
            }
            if (withdrawalAmount != 0)
            {
                withdrawal.Message = "Valor inválido. Sacando o valor mais próximo...";
            }
            return(withdrawal);
        }
Пример #2
0
        public void Withdrawal_should_be_created_for_given_values(decimal value)
        {
            var withdrawal = new Withdrawal(value, _users[0]);

            withdrawal.UserFrom.Id.Should().Be(_users[0].Id);
            withdrawal.Amount.Should().Be(value);
        }
Пример #3
0
        public async Task CreateAsync(WithdrawalCreateInputModel withdrawalCreateInputModel, string userId)
        {
            var user = this.usersRepository.All()
                       .FirstOrDefault(x => x.Id == userId);

            var pendingWithdrawals = await this.GetUserPendingWithdrawalsBalance(userId);

            var withdrawableAmount = user.Balance - pendingWithdrawals;

            if (withdrawableAmount >= withdrawalCreateInputModel.Amount && withdrawalCreateInputModel.Amount > 0)
            {
                var withdrawal = new Withdrawal
                {
                    Amount = withdrawalCreateInputModel.Amount,
                    AdditionalInstructions = withdrawalCreateInputModel.AdditionalInstructions,
                    TrainConnectedUserId   = user.Id,
                    TrainConnectedUser     = user,
                    Status = StatusCode.Initiated,
                };

                await this.withdrawalsRepository.AddAsync(withdrawal);

                await this.withdrawalsRepository.SaveChangesAsync();
            }
            else
            {
                throw new InvalidOperationException(string.Format(ServiceConstants.Withdrawal.RequestedAmountGreaterThanWithdrawable));
            }
        }
Пример #4
0
 public IActionResult ReadWithdrawal(string contractAddress)
 {
     if (!string.IsNullOrEmpty(ConnectionId))
     {
         Task.Factory.StartNew(() =>
         {
             var hubContext = HubConnectionManager.GetHubContext <AuctusDemoHub>();
             try
             {
                 Withdrawal withdrawal = PensionFundsServices.ReadWithdrawal(contractAddress);
                 if (withdrawal == null || withdrawal.Completed)
                 {
                     hubContext.Clients.Client(ConnectionId).withdrawalCompleted(Json(withdrawal).Value);
                 }
                 else
                 {
                     hubContext.Clients.Client(ConnectionId).withdrawalUncompleted(Json(withdrawal).Value);
                 }
             }
             catch (Exception ex)
             {
                 Logger.LogError(new EventId(3), ex, string.Format("Erro on ReadWithdrawal {0}.", contractAddress));
                 hubContext.Clients.Client(ConnectionId).readWithdrawalError();
             }
         });
         return(Json(new { success = true }));
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
Пример #5
0
        public async Task <bool> Withdrawal(Guid idAccount, double amount)
        {
            var account = _accountService.GetAccountById(idAccount).Result;
            var bank    = _bankService.GetBankById(account.IdBank);

            if (account.Invalid && bank.Invalid)
            {
                return(false);
            }

            Withdrawal withdrawal = new Withdrawal(amount, DateTime.Now, account, bank);

            if (WithdrawalMade(withdrawal) is false)
            {
                return(false);
            }

            var updatedAccount = await _accountService.UpdateAccount(account);

            if (UpdateMade(updatedAccount) is false)
            {
                return(false);
            }

            var bankStatement         = new BankStatement(Enum.GetName(typeof(TransactionType), TransactionType.Withdrawal), DateTime.Now, amount, account.Balance, account.Id, account.IdOwner);
            var insertedBankStatement = await _bankStatementService.RegisterBankStatement(bankStatement);

            return(updatedAccount && insertedBankStatement);
        }
Пример #6
0
        public void Serialization()
        {
            const string           id         = "1234567890";
            var                    asset      = Asset.BTC;
            const decimal          amount     = 1.23m;
            const long             timestamp  = 1234567890;
            const WithdrawalStatus status     = WithdrawalStatus.Completed;
            const string           address    = "0x12345678901234567890";
            const string           addressTag = "ABCDEF";
            const string           txId       = "21436587092143658709";

            var withdrawal = new Withdrawal(id, asset, amount, timestamp, status, address, addressTag, txId);

            var json = JsonConvert.SerializeObject(withdrawal);

            withdrawal = JsonConvert.DeserializeObject <Withdrawal>(json);

            Assert.Equal(id, withdrawal.Id);
            Assert.Equal(asset, withdrawal.Asset);
            Assert.Equal(amount, withdrawal.Amount);
            Assert.Equal(timestamp, withdrawal.Timestamp);
            Assert.Equal(status, withdrawal.Status);
            Assert.Equal(address, withdrawal.Address);
            Assert.Equal(addressTag, withdrawal.AddressTag);
            Assert.Equal(txId, withdrawal.TxId);
        }
Пример #7
0
        public void TestAddWithdrawalWithValidData()
        {
            var withdrawal = new Withdrawal
            {
                Publications = new List <Publication>
                {
                    new Publication
                    {
                        NumberOfPages = 425,
                        Book          = new Book {
                            Domains = new List <Domain> {
                                new Domain {
                                    Name = "Science"
                                }
                            }, Name = "Stars and galaxies"
                        },
                        Stock = new Stock {
                            InitialStock = 50, RentedStock = 0, NumberOfBooksForLecture = 10
                        }
                    }
                },
                Extensions = new List <Extension>(),
                Reader     = new Reader {
                    Withdrawals = new List <Withdrawal>()
                },
                RentedDate = DateTime.Today.AddDays(-5),
                DueDate    = DateTime.Today.AddDays(10)
            };

            var results = this.WithdrawalService.Create(withdrawal);

            Assert.IsEmpty(results);
            this.LibraryContextMock.Verify(b => b.SaveChanges(), Times.Once());
        }
Пример #8
0
        public async Task <ActionResult <Withdrawal> > PostWithdrawal(Withdrawal withdrawal, [FromServices] AccountService _accountService)
        {
            try {
                var account = await _accountService.Get(withdrawal.AccountId);

                if (account == null)
                {
                    log.Warn($"Account {withdrawal.AccountId} not found.");
                    return(BadRequest("Account not found.")); // use proper error obj
                }

                account.UpdateBalance(withdrawal.Amount * -1);
                await _accountService.Update(account.Id, account);

                Withdrawal createdWithdrawal = await _transactionService.Create(withdrawal);

                log.Info($"Withdrawal {createdWithdrawal.Id} has been created.");
                return(createdWithdrawal);
            } catch (Exception e) {
                log.Error(e);
                return(BadRequest(new {
                    error = new { message = e.Message }
                }));
            }
        }
Пример #9
0
    // return object of specified Transaction derived class
    private Transaction CreateTransaction(int type)
    {
        Transaction temp = null; // null Transaction reference

        // determine which type of Transaction to create
        switch ((MenuOption)type)
        {
        // create new BalanceInquiry transaction
        case MenuOption.BALANCE_INQUIRY:
            temp = new BalanceInquiry(currentAccountNumber,
                                      screen, bankDatabase);
            break;

        case MenuOption.WITHDRAWAL:  // create new Withdrawal transaction
            temp = new Withdrawal(currentAccountNumber, screen,
                                  bankDatabase, keypad, cashDispenser);
            break;

        case MenuOption.DEPOSIT:  // create new Deposit transaction
            temp = new Deposit(currentAccountNumber, screen,
                               bankDatabase, keypad, depositSlot);
            break;
        }

        return(temp);
    }
Пример #10
0
        private static async Task <bool> ProcessWithdraw(Withdrawal wd)
        {
            WithdrawInfo result = new WithdrawInfo();

            if (await repository.Contains(wd.HashStr))
            {
                result = await repository.Get(wd.HashStr);
            }
            else
            {
                result.Asset     = wd.Asset;
                result.HashStr   = wd.HashStr;
                result.Timestamp = DateTime.Now;
                await repository.Save(result);
            }

            if (wd.Asset == "BTC")
            {
                result.TxHash = await btcConnector.WithdrawBtc(wd.HashStr, wd.TargetWallet, wd.Size);
            }
            else
            {
                await ethConnector.WithdrawEth(wd.HashStr, wd.TargetWallet, wd.Size, wd.Asset);
            }

            result.Status = WithdrawStatus.Sent;

            withdrwawalDictionary.Add(wd.HashStr, wd);
            await repository.Save(result);

            return(true);
        }
Пример #11
0
        public async Task Execute(InitWithdrawalModel initWithdrawalModel, PerformContext context)
        {
            context.WriteLine($"InitWithdrawalJob started with data: {JsonConvert.SerializeObject(initWithdrawalModel)}");

            var matrixPositionInLineB = await _matrixPositionRepository.GetAsync(initWithdrawalModel.MatrixPositionId);

            context.WriteLine($"Matrix position data: {JsonConvert.SerializeObject(matrixPositionInLineB)}");

            var matrixOwner = await _matrixPositionHelper.GetTopParentAsync(matrixPositionInLineB, matrixPositionInLineB.MatrixLevel);

            context.WriteLine($"Matrix owner data: {JsonConvert.SerializeObject(matrixOwner)}");

            if (!matrixOwner.UserMultiAccountId.HasValue)
            {
                throw new InvalidOperationException($"Matrix owner position with ID {matrixOwner.Id} does not assigned multi account.");
            }

            var amountToWithdraw = _withdrawalHelper.CalculateAmountToWithdraw(matrixOwner.MatrixLevel);

            var withdrawal = new Withdrawal(
                Guid.NewGuid(),
                matrixOwner.UserMultiAccountId.Value,
                amountToWithdraw,
                PaymentSystemType.BitBayPay,
                initWithdrawalModel.WithdrawalFor);

            BackgroundJob.Enqueue <CommitWithdrawalJob>(
                job => job.Execute(withdrawal, null));

            // TODO: WithdrawJob in the future to process automatically withdrawal via payment system to the user's btc wallet

            context.WriteLine("InitWithdrawalJob completed");
        }
 public static void DisplayCharges(Withdrawal muenzen)
 {
     WriteLine(muenzen.AccountOwnerName);
     WriteLine(muenzen.withdrawal);
     WriteLine(muenzen.charge);
     WriteLine("********************");
 }
Пример #13
0
        public void ToStringItSelf()
        {
            var withdrawal           = new Withdrawal(new DateTime(2017, 2, 21), 100.00D, 150.00D);
            var stringRepresentation = withdrawal.ToString();

            Assert.That(stringRepresentation, Is.EqualTo("21/02/2017 | | 100.00 | 150.00"));
        }
Пример #14
0
 public MainPage()
 {
     InitializeComponent();
     HandleThemes();
     SetLanguage();
     Withdrawal.Focus();
 }
Пример #15
0
        public async Task <IActionResult> PutWithdrawal(int id, Withdrawal withdrawal)
        {
            if (id != withdrawal.Id)
            {
                return(BadRequest());
            }

            _context.Entry(withdrawal).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WithdrawalExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        // GET: Transactions/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Transaction transaction = db.Transactions.Find(id);


            if (transaction == null)
            {
                return(HttpNotFound());
            }

            Withdrawal withdrwal = new Withdrawal();

            withdrwal.TranscationGuid = Guid.NewGuid();

            withdrwal.TranscationForGuid = transaction.TranscationForGuid;
            withdrwal.PersonGuid         = transaction.PersonGuid;
            withdrwal.Amount             = transaction.Amount;
            withdrwal.Interest           = transaction.Interest;
            withdrwal.TransactionDate    = transaction.TransactionDate;
            return(View(withdrwal));
        }
Пример #17
0
        public void Serialization()
        {
            const string           id         = "1234567890";
            var                    asset      = Asset.BTC;
            const decimal          amount     = 1.23m;
            var                    time       = DateTimeOffset.FromUnixTimeMilliseconds(DateTime.UtcNow.ToTimestamp()).UtcDateTime;
            const WithdrawalStatus status     = WithdrawalStatus.Completed;
            const string           address    = "0x12345678901234567890";
            const string           addressTag = "ABCDEF";
            const string           txId       = "21436587092143658709";

            var withdrawal = new Withdrawal(id, asset, amount, time, status, address, addressTag, txId);

            var json = JsonConvert.SerializeObject(withdrawal);

            withdrawal = JsonConvert.DeserializeObject <Withdrawal>(json);

            Assert.Equal(id, withdrawal.Id);
            Assert.Equal(asset, withdrawal.Asset);
            Assert.Equal(amount, withdrawal.Amount);
            Assert.Equal(time, withdrawal.Time);
            Assert.Equal(status, withdrawal.Status);
            Assert.Equal(address, withdrawal.Address);
            Assert.Equal(addressTag, withdrawal.AddressTag);
            Assert.Equal(txId, withdrawal.TxId);
        }
Пример #18
0
        public async Task <Balance> WithdrawFundsAsync(Withdrawal withdrawal)
        {
            decimal entryAmount    = withdrawal.Amount;
            Balance currentBalance = await GetBalanceAsync();

            decimal currentBalanceAmount = currentBalance.Amount;

            if (entryAmount > currentBalance.Amount)
            {
                throw new InsufficientBalanceException();
            }

            entryAmount *= -1;

            WalletEntry withdrawalEntry = new WalletEntry()
            {
                Amount        = entryAmount,
                BalanceBefore = currentBalanceAmount,
                EventTime     = DateTimeOffset.UtcNow
            };

            await _walletRepository.InsertWalletEntryAsync(withdrawalEntry);

            Balance newBalance = new Balance
            {
                Amount = currentBalanceAmount + entryAmount
            };

            return(newBalance);
        }
Пример #19
0
        public IActionResult Withdraw(Guid accountId, [FromBody] Withdrawal withdrawal)
        {
            var result = _accountService.Withdraw(accountId, withdrawal.Amount);

            if (result.Status == WithdrawStatus.Success)
            {
                return(NoContent());
            }
            else if (result.Status == WithdrawStatus.AccountNotFound)
            {
                return(this.NotFoundResource(new AccountNotFoundProblem(accountId)));
            }
            else if (result.Status == WithdrawStatus.DailyQuotaReached)
            {
                return(this.BadRequestResource(new DailyQuotaReachedProblem(result.DailyLimit)));
            }
            else if (result.Status == WithdrawStatus.AccountDoesNotAllowWithdrawals)
            {
                return(this.BadRequestResource(new AccountDoesNotAllowWithdrawalsProblem()));
            }
            else //if (result.Status == WithdrawStatus.InsufficientFunds)
            {
                return(this.BadRequestResource(new InsufficientFundsProblem(result.AvailableFunds)));
            }
        }
Пример #20
0
        /// <summary>Convert an exchange withdrawal to a CoinFlip transfer</summary>
        private Transfer TransferFrom(Withdrawal wit)
        {
            var coin   = Coins.GetOrAdd(wit.Asset);
            var amount = wit.Amount._(coin);

            return(new Transfer(wit.TxId, ETransfer.Withdrawal, coin, amount, wit.ApplyTime, ToTransferStatus(wit.Status)));
        }
Пример #21
0
        public async Task TestGetForProcessingAsync_WithIncorrectData_ShouldThrowNullRefEx()
        {
            var testUserId            = "testUserId";
            var testWithdrawalId      = "testWithdrawalId";
            var incorrectWithdrawalId = "incorrectWithdrawalId";

            var user = new TrainConnectedUser()
            {
                Id      = testUserId,
                Balance = 100.00m,
            };

            await this.usersRepository.AddAsync(user);

            await this.usersRepository.SaveChangesAsync();

            var withdrawal = new Withdrawal()
            {
                Amount               = 10.05m,
                Id                   = testWithdrawalId,
                CreatedOn            = DateTime.Now,
                TrainConnectedUserId = testUserId,
                TrainConnectedUser   = user,
                Status               = StatusCode.Initiated,
            };

            await this.withdrawalsRepository.AddAsync(withdrawal);

            await this.withdrawalsRepository.SaveChangesAsync();

            await Assert.ThrowsAsync <NullReferenceException>(async() => await this.withdrawalsService.GetForProcessingAsync(incorrectWithdrawalId));
        }
Пример #22
0
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            try
            {
                Withdrawal       calc        = new Withdrawal();
                int              valueDrawee = Convert.ToInt32(txtValueDrawee.Text);
                Tuple <int, int> tupleRemainder;

                tupleRemainder = calc.Calculate(valueDrawee, Withdrawal.enumMoneyValue.fifty, amountCashValue50);

                txtAmountCashValue50.Text = tupleRemainder.Item1.ToString();

                tupleRemainder            = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.Twenty, amountCashValue20);
                txtAmountCashValue20.Text = tupleRemainder.Item1.ToString();

                tupleRemainder            = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.Ten, amountCashValue10);
                txtAmountCashValue10.Text = tupleRemainder.Item1.ToString();

                tupleRemainder           = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.fife, amountCashValue5);
                txtAmountCashValue5.Text = tupleRemainder.Item1.ToString();

                tupleRemainder           = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.Two, 0);
                txtAmountCashValue2.Text = tupleRemainder.Item1.ToString();



                CacheCashValues();
            }
            catch (Exception ex)
            {
                RetriaverCach();

                MessageBox.Show(ex.Message);
            }
        }
Пример #23
0
        public void test()
        {
            var pvtKey = "jqWoAa/jvXSc3QQVl0lI/s9MbeqkIBXOvVx08EKyfNk=";
            var pubKey = "6ZfNdq3EtXLJWX2kJAAgMoIgUUOZEKoJaOWl3e0muZM=";
            // var pvtKey = "KyfOaCCa7wBaMjMsw1JmTYeBObpYQYPBmj+dsuPf1sU=";
            // var pubKey = "BKOJ0U4+VgUTXkfEPjCst4+N+cgxVU6taNALpUnJnA/zbfAkcV7cd6INvBKWH3xT0wr0uHXfWYtKuUowwOG2DeI=";
            decimal quantity = 2;
            var     wd       = new Withdrawal();

            wd.SourceWallet = pubKey;
            wd.TargetWallet = "asdfasdf";
            wd.Asset        = "BTC";
            wd.Size         = quantity;
            wd.Signature    = CryptoHelper.Sign(wd.ToString(), pvtKey);

            wd.BuildHash();

            RestClient client  = new RestClient("http://localhost:5000/");
            var        request = new RestRequest("api/withdrawal", Method.POST);

            request.AddParameter("sourceWallet", pubKey);
            request.AddParameter("targetWallet", wd.TargetWallet);
            request.AddParameter("asset", wd.Asset);
            request.AddParameter("quantity", quantity);
            request.AddParameter("signature", wd.Signature);

            var response = client.Post(request);
        }
        public ActionResult Edit(Withdrawal withdraw)
        {
            if (ModelState.IsValid)
            {
                Transaction transaction = db.Transactions.FirstOrDefault(x => x.TranscationGuid == withdraw.TranscationGuid);

                if (transaction == null)
                {
                    return(HttpNotFound());
                }

                log.Info(withdraw.TranscationGuid);
                log.Info(transaction.TranscationGuid);
                transaction.TranscationForGuid = withdraw.TranscationForGuid;
                transaction.PersonGuid         = withdraw.PersonGuid;
                transaction.Amount             = withdraw.Amount;
                transaction.Interest           = withdraw.Interest;
                transaction.TransactionDate    = withdraw.TransactionDate;
                db.Entry(transaction).State    = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Transactions"));
            }
            ViewBag.TransactionFor = new SelectList(db.TransactionFor.Where(x => x.TransactionType == 2), "TranscationForGuid", "TranscationFor");
            ViewBag.PersonGuid     = new SelectList(db.Persons, "PersonGuid", "LoginId", withdraw.PersonGuid);
            return(View(withdraw));
        }
Пример #25
0
        public void TestUpdateWithdrawalWithNullData()
        {
            Withdrawal nullWithdrawal = null;

            Assert.Throws <ArgumentNullException>(() => this.WithdrawalService.Update(nullWithdrawal));
            this.LibraryContextMock.Verify(b => b.SaveChanges(), Times.Never());
        }
        // GET: Transactions/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Transaction transaction = db.Transactions.Find(id);

            if (transaction == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TransactionFor = new SelectList(db.TransactionFor.Where(x => x.TransactionType == 2), "TranscationForGuid", "TranscationFor");
            ViewBag.PersonGuid     = new SelectList(db.Persons, "PersonGuid", "LoginId", transaction.PersonGuid);

            Withdrawal withdrwal = new Withdrawal();

            withdrwal.TranscationGuid = transaction.TranscationGuid;

            withdrwal.TranscationForGuid = transaction.TranscationForGuid;
            withdrwal.PersonGuid         = transaction.PersonGuid;
            withdrwal.Amount             = transaction.Amount;
            withdrwal.Interest           = transaction.Interest;
            withdrwal.TransactionDate    = transaction.TransactionDate;
            return(View(withdrwal));
        }
        public async Task <Withdrawal> Create(Withdrawal withdrawal)
        {
            _context.Withdrawals.Add(withdrawal);
            await _context.SaveChangesAsync();

            return(withdrawal);
        }
Пример #28
0
    public Withdrawal getWithdrawal(string id)
    {
        Withdrawal ret = null;

        idToWithdrawal.TryGetValue(id, out ret);
        return(ret);
    }
Пример #29
0
        static void Main(string[] args)
        {
            Nessie n = new Nessie();

            Deposit d = new Deposit();

            d.idInput         = "5bcb8c20322fa06b67793e29";
            d.mediumInput     = "balance";
            d.amountInput     = 100.0;
            d.transactionDate = "1-2";

            if (!n.makeDeposit(d))
            {
                Console.WriteLine("Cannot deposit");
            }

            Withdrawal w = new Withdrawal();

            w.idInput         = "5bcb8c20322fa06b67793e29";
            w.mediumInput     = "balance";
            w.amountInput     = 100.0;
            w.transactionDate = "1-2";

            if (!n.makeWithdrawal(w))
            {
                Console.WriteLine("Cannot withdraw");
            }
        }
Пример #30
0
        public async Task <bool> Create([FromBody] WithdrawalModel model)
        {
            try
            {
                var wd = new Withdrawal();

                wd.SourceWallet   = model.SourceWallet;
                wd.TargetWallet   = model.TargetWallet;
                wd.Asset          = model.Asset;
                wd.Size           = model.Size;
                wd.Signature      = model.Signature;
                wd.TimeStampTicks = model.Timestamp;
                wd.OracleAdrress  = model.OracleAddress;
                wd.OracleFee      = model.OracleFee;
                wd.BuildHash();

                return(await repository.AppendWithdrawal(wd));
            }
            catch (Exception e)
            {
                e.ToString();
            }

            return(false);
        }
Пример #31
0
 private Transaction createTransaction(int type)
 {
     Transaction tempPtr = null;
     switch (type)
     {
         case 1:
             tempPtr = new Balancelnquiry(currentPIN, screen, bankDatabase);
             break;
         case 2:
             tempPtr = new Withdrawal(currentPIN, screen, bankDatabase, cashDispenser);
             break;
         case 3:
             tempPtr = new Deposit(currentPIN, screen, bankDatabase, depositSlot, cashDispenser);
             break;
         case 4:
             tempPtr = new Transfer(currentPIN, screen, bankDatabase);
             break;
     }
     return tempPtr;
 }
Пример #32
0
    // return object of specified Transaction derived class
    private Transaction CreateTransaction( int type )
    {
        Transaction temp = null; // null Transaction reference

          // determine which type of Transaction to create
          switch ( ( MenuOption ) type )
          {
         // create new BalanceInquiry transaction
         case MenuOption.BALANCE_INQUIRY:
            temp = new BalanceInquiry( currentAccountNumber,
               screen, bankDatabase);
            break;
         case MenuOption.WITHDRAWAL: // create new Withdrawal transaction
            temp = new Withdrawal( currentAccountNumber, screen,
               bankDatabase, keypad, cashDispenser);
            break;
         case MenuOption.DEPOSIT: // create new Deposit transaction
            temp = new Deposit( currentAccountNumber, screen,
               bankDatabase, keypad, depositSlot);
            break;
          } // end switch

          return temp;
    }