コード例 #1
0
        public void ProcessPurchase(Purchase p, Account a, IList <Transaction> tt)
        {
            Factory factory = Factory.GetInstance();



            IAccountSvc AccountSvc =
                (IAccountSvc)factory.GetService(typeof(IAccountSvc).Name);
            ITransactionSvc TransactionSvc =
                (ITransactionSvc)factory.GetService(typeof(ITransactionSvc).Name);

            TransactionSvc.ProcessTransaction(p, tt);



            var entry = from e in a.Entries
                        where e.Currency == p.Currency
                        select e;

            //Subtract cost
            if (entry.FirstOrDefault() != null)
            {
                entry.FirstOrDefault().Amount -= p.Cost;
            }

            //Display message if for some reason we don't have any of the currency
            else
            {
                Console.WriteLine("ERROR: CANNOT EXCHANGE CURRENCY: " + p.Currency);
            }

            AccountSvc.GenerateJSON(a);
        }
コード例 #2
0
        public void ProcessExchange(Exchange d, Account a, IList <Transaction> tt)
        {
            Factory factory = Factory.GetInstance();



            IAccountSvc AccountSvc =
                (IAccountSvc)factory.GetService(typeof(IAccountSvc).Name);
            ITransactionSvc TransactionSvc =
                (ITransactionSvc)factory.GetService(typeof(ITransactionSvc).Name);

            TransactionSvc.ProcessTransaction(d, tt);



            var entry = from e in a.Entries
                        where e.Currency == d.OutCurr
                        select e;

            //Add to the currency if it's already there
            if (entry.FirstOrDefault() != null)
            {
                entry.FirstOrDefault().Amount += d.OutAmt;
            }
            //If the currency isn't there yet, we must add it
            else
            {
                CurrEntry c = new CurrEntry(d.OutAmt, d.OutCurr);
                a.AddCurrency(c);
            }

            var entry2 = from e2 in a.Entries
                         where e2.Currency == d.InCurr
                         select e2;

            if (entry2.FirstOrDefault() != null)
            {
                entry2.FirstOrDefault().Amount -= d.InAmt;
            }
            //Display message if for some reason we don't have any of the input currency
            else
            {
                Console.WriteLine("ERROR: CANNOT EXCHANGE CURRENCY: " + d.InCurr);
            }

            AccountSvc.GenerateJSON(a);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            string         diResolverPath = System.Configuration.ConfigurationManager.AppSettings["DIResolverPath"];
            StandardKernel kernel         = new StandardKernel();

            kernel.Load(diResolverPath);
            try
            {
                Console.WriteLine("*** RUNNING TRANSACTION RULES ***");
                Console.WriteLine("*** WINDOW WILL BE CLOSED AUTOMATICALLY WHEN COMPLETED ***");
                Console.WriteLine("*** PLEASE DON'T CLOSE WINDOW ***");

                ITransactionSvc trnsSvc = kernel.Get <ITransactionSvc>();
                trnsSvc.AddRegularTransactions();
                trnsSvc.CheckDuesAndAddFine();
                trnsSvc.CheckLibraryDueAndAddFine();
            }
            catch (Exception exp)
            {
                ILogSvc logger = kernel.Get <ILogSvc>();
                logger.Log(exp);
            }
        }
コード例 #4
0
        public void ProcessDeposit(Deposit d, Account a, IList <Transaction> tt)
        {
            Factory     factory    = Factory.GetInstance();
            IAccountSvc AccountSvc =
                (IAccountSvc)factory.GetService(typeof(IAccountSvc).Name);


            ITransactionSvc TransactionSvc =
                (ITransactionSvc)factory.GetService(typeof(ITransactionSvc).Name);


            TransactionSvc.ProcessTransaction(d, tt);



            var entry = from e in a.Entries
                        where e.Currency == d.Currency
                        select e;

            //Add to the currency if it's already there
            if (entry.FirstOrDefault() != null)
            {
                entry.FirstOrDefault().Amount += d.Amt;
            }
            //If the currency isn't there yet, we must add it
            else
            {
                CurrEntry c = new CurrEntry(d.Amt, d.Currency);
                a.AddCurrency(c);
            }

            AccountSvc.GenerateJSON(a);
            Console.WriteLine();
            Console.WriteLine(d.ToString());
            Console.WriteLine();
        }