Example #1
0
        public bool transact()
        {
            try
            {
                if (!AccountXmlLoader.checkIfExists(this.ReceiverID))
                {
                    throw new Exception("Receiver not found");
                }

                Account sender   = AccountXmlLoader.pull(this.SenderID);
                Account receiver = AccountXmlLoader.pull(this.ReceiverID);


                //no commision
                if (receiver.currency == this.currency)
                {
                    receiver.Balance += this.Sum;
                }
                else
                {
                    double defaultvalue          = this.Sum * (double)CurrencyProcessor.convertCoeficient(this.currency);
                    double receiverCurrencyValue =
                        defaultvalue / (double)CurrencyProcessor.convertCoeficient(receiver.currency);
                    receiver.Balance += receiverCurrencyValue;
                }
                AccountXmlLoader.update(receiver);
                this.Verified = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                this.Verified = false;
            }
            finally
            {
                TransactionXmlLoader.push(this);
            }
            return(this.Verified);
        }
Example #2
0
 public static bool checkIfExists(string id)
 {
     return(AccountXmlLoader.pull(id) != null ? true : false);
 }