コード例 #1
0
ファイル: Program.cs プロジェクト: erinloy/ivento-dci
        private static void PayBills(ref Account source, bool enoughMoney = true)
        {
            // Create some creditors that wants money from the supplied account.
            // CreditorsList is a class similar to LedgersList, defined to play the role of
            // "Creditors" in the PayBills context.
            var creditors = new CreditorsList
            {
                new Creditor
                {
                    Name       = "Baker",
                    Account    = new Account(new LedgersList()),
                    AmountOwed = 150m
                },

                new Creditor
                {
                    Name       = "Butcher",
                    Account    = new Account(new LedgersList()),
                    AmountOwed = 200m
                }
            };

            // Create a new account with little money if enoughMoney is false.
            if (!enoughMoney)
            {
                source = new Account(new LedgersList
                {
                    new LedgerEntry {
                        Message = "From mom", Amount = 80m
                    }
                }
                                     );
            }


            // Create the context using the supplied account and the creditors.
            var context = new PayBills(source, creditors);

            Console.WriteLine("BEFORE");
            Console.WriteLine("Source account           " + source.Balance.ToString("c"));

            Console.WriteLine();
            Console.WriteLine("PAYING BILLS");
            creditors.ForEach(Console.WriteLine);

            // Execute the context.
            try
            {
                context.Execute();
            }
            catch (AccountException e)
            {
                Console.WriteLine();
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            Console.WriteLine("AFTER");
            Console.WriteLine("Source account           " + source.Balance.ToString("c"));
        }
コード例 #2
0
        public ActionResult Pay(PayBills pay)
        {
            bool res = false;

            try
            {
                IBusinessBanking ibank = GenericFactory <Business, IBusinessBanking> .GetInstance();

                UserInfo ui         = CookieFacade.USERINFO;
                int      selectedID = pay.selectedBill;
                pay.billPayments = ibank.GetUnPaidBills(ui.Username);
                BillPayment Bill = null;
                foreach (BillPayment bill in pay.billPayments)
                {
                    if (bill.BillID == selectedID)
                    {
                        Bill = bill;
                        break;
                    }
                }
                if (Bill != null)
                {
                    res = ibank.payBill(ui.CheckingAcccountNumber, Bill.BillID, Bill.Amount);
                    if (res)
                    {
                        ViewBag.Message = "Bill Paid";
                        ModelState.Clear();
                        pay.selectedBill = 0;
                    }
                }
                else
                {
                    ViewBag.Message = "This bill is already paid";
                    ModelState.Clear();
                    pay.selectedBill = 0;
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
            }

            return(View(pay));
        }
コード例 #3
0
        public ActionResult Pay()
        {
            PayBills pay = new PayBills();

            try
            {
                IBusinessBanking ibank = GenericFactory <Business, IBusinessBanking> .GetInstance();

                UserInfo           ui           = CookieFacade.USERINFO;
                List <BillPayment> billPayments = ibank.GetUnPaidBills(ui.Username);
                pay.billPayments = billPayments;
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
            }

            return(View(pay));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //var web = SPContext.Current.Web;
            if (!IsPostBack)
            {
                var pageTitle = HttpContext.GetGlobalResourceObject("napas.resource", "PayBills").ToString();
                SetPageTitles(pageTitle);

                var topupBo   = new PayBills(SPContext.Current.Web);
                var partnerBo = new PartnersCustomers(SPContext.Current.Web);
                var customer  = topupBo.get_PaybillsInfoInfo();
                if (customer.Id > 0)
                {
                    ltHeader.Text  = customer.Title;
                    ltContent.Text = customer.Content;
                    ltNote.Text    = customer.Note;

                    rpBanks.DataSource = partnerBo.Get_PartnersCustomersInfoByIds(customer.Banks);
                    rpBanks.DataBind();
                }
            }
        }
コード例 #5
0
ファイル: MoneyTransfer.cs プロジェクト: ciscoheat/ivento-dci
 // When the Context is created, the Roles will be bound using the supplied arguments.
 // There can be multiple constructors with different ways of retreiving the objects
 // needed for the binding (database lookup, web service, etc), but there can only be
 // one BindRoles method, which does the final Role binding.
 // The constructor(s) should be strongly typed to check for errors.
 public MoneyTransfer(PayBills.SourceAccountRole source, Account destination, decimal amount)
 {
     BindRoles(source, destination, amount);
 }