Beispiel #1
0
        private void WithdrawFromAccount()
        {
            decimal withdrawed = bankAccount.CoinsParser();

            if (withdrawed <= bankAccount.AccountAmount)
            {
                bankAccount.AccountAmount -= withdrawed;
                Notify?.Invoke($"From Account Withdrawed {withdrawed} coins");
            }
            else
            {
                NotifyError?.Invoke($"Insufficient Funds!");
            }
            ShowMenu();
        }
Beispiel #2
0
        public bool Create(Person item)
        {
            if (item == null)
            {
                throw new InvalidOperationException("The person to create can't be null");
            }

            var created          = false;
            var validationResult = _validator.Validate(item);

            if (validationResult.HasError)
            {
                NotifyError?.Invoke(this, validationResult);
            }
            else
            {
                created = _repository.Create(item);
            }

            return(created);
        }
Beispiel #3
0
        public bool Update(Company item)
        {
            if (item == null)
            {
                throw new InvalidOperationException("The company can't be null");
            }

            var updated          = false;
            var validationResult = _validator.Validate(item);

            if (validationResult.HasError)
            {
                NotifyError?.Invoke(this, validationResult);
            }
            else
            {
                updated = _repository.Update(item);
            }

            return(updated);
        }
Beispiel #4
0
 void SafeNotifyError(string message, Exception ex)
 {
     NotifyError?.Invoke(message, ex);
 }