public HeadOffice Handle(TransferCashToAtmCommand request)
        {
            var headOffice = _headOfficeRepository.GetById(request.HeadOfficeId);
            var atm        = _atmRepository.GetById(request.AtmId);

            headOffice.TransferCashToAtm(atm);

            _atmRepository.Save(atm);
            _headOfficeRepository.Save(headOffice);

            return(headOffice);
        }
        public Atm Handle(WithdrawCommand request)
        {
            var atm = _atmRepository.GetById(request.AtmId);

            if (atm.Withdraw(request.Amount))
            {
                var charge = request.Amount + atm.CalculateCommision(request.Amount);

                _paymentGateway.ChargePayment(charge);

                _atmRepository.Save(atm);
            }

            return(atm);
        }
Beispiel #3
0
        private void TakeMoney(decimal amount)
        {
            var error = _atm.CanTake(amount);

            if (error != string.Empty)
            {
                MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            var amountWithComission = _atm.CalculateWithComission(amount);

            _paymentGateway.ChargePayment(amountWithComission);
            _atm.TakeMoney(amount);
            _atmRepository.Save(_atm);
            NotifyClient($"You have taken {amount.ToString("C2")}");
        }
Beispiel #4
0
 private static void SetupAtm(IAtmRepository atmRepository)
 {
     var atm = new Atm() {Id = 1};
     atm.LoadMoney(new Money(20,20,20,20,20,20));
     atmRepository.Save(atm);
 }