private void btnWithdraw_Click(object sender, EventArgs e) { WithdrawFromAccount withdrawFromAccount = new WithdrawFromAccount(); withdrawFromAccount.Show(); Hide(); }
public async Task <Unit> Handle(WithdrawFromAccount command, CancellationToken token = default) { await _repository.UpdateAsync( new AccountId(command.AccountId), account => account.Withdraw(new Money(command.Amount)), token); return(Unit.Value); }
public async Task <IActionResult> Withdraw( [FromHeader(Name = Headers.RequestId)] Guid requestId, Guid id, WithdrawFromAccountDto requestDto, CancellationToken token) { RequestContext.RequestId = requestId; RequestContext.CausationId = requestId; RequestContext.CorrelationId = requestId; var command = new WithdrawFromAccount(id, requestDto.Amount); await _mediator.Send(command, token); return(Ok()); }
public void Run() { Console.WriteLine("Please enter your name:"); var clientName = Console.ReadLine(); Console.Clear(); Console.WriteLine($"{clientName}, What is your initial deposit?"); _clientBalance = decimal.Parse(Console.ReadLine()); Console.WriteLine($"Are you a Gold member? y/n"); var memberResponse = Console.ReadLine(); if (memberResponse == "y" || memberResponse == "Y") { _newAccount = new GoldLevelEmployee(); } else { _newAccount = new Employee(); } _seeBalance = new SeeAccountBalance(_newAccount, _clientBalance); _withdraw = new WithdrawFromAccount(_newAccount, _clientBalance); _deposit = new DepositToAccount(_newAccount, _clientBalance); _invoker = new AccountInvoker(_seeBalance, _withdraw, _deposit); Console.WriteLine($"Welcome {clientName} To Account Manager!" + $"\n\nPress any key to continue..."); Console.ReadKey(); var response = true; while (response) { Console.WriteLine($"\nWhat would you like to do?\n\t" + "1. See funds.\n\t" + "2. Deposit funds.\n\t" + "3. Withdraw funds.\n\t" + "4. See Account History\n\t" + "5. Revert action\n\t" + "6. Exit."); var menuResponse = int.Parse(Console.ReadLine()); Console.Clear(); switch (menuResponse) { case 1: _invoker.SeeBalance(); break; case 2: decimal deposit = 0m; Console.WriteLine("How much will you be depositing?"); deposit = decimal.Parse(Console.ReadLine()); _invoker.Deposit(deposit); break; case 3: UIWithdraw(); break; case 4: Console.WriteLine("We apologize. This feature is not yet available."); break; case 5: Console.WriteLine("We apologize. This feature is not yet available."); break; case 6: response = false; break; } } }