示例#1
0
        public ActionResult New(int id)
        {
            var customerAccount = _customerAccContext.Get(id);
            var viewModel       = new TellerPostViewModel
            {
                CustomerAccount = customerAccount,
            };

            return(View("TellerPostForm", viewModel));
        }
示例#2
0
        public ActionResult Save(TellerPost tellerPost)
        {
            tellerPost.CustomerAccountId = Convert.ToInt32(Request.Form["accountId"]);
            tellerPost.TellerId          = Convert.ToInt32(Session["Id"]);
            var customerAccount = _customerAccContext.Get(Convert.ToInt32(Request.Form["accountId"]));
            var currentConfig   = _accountTypeConfigContext.GetCurrentConfig();

            if (currentConfig == null)      //check if current account configurations have been set
            {
                TempData["error"] = "Account Configuration Not Set";
                var viewModel = new TellerPostViewModel
                {
                    CustomerAccount = customerAccount,
                };
                return(View("TellerPostForm", viewModel));
            }

            //check if customer account is open
            if (!customerAccount.IsOpen)
            {
                TempData["error"] = "Customer Account is Closed Set";
                var viewModel = new TellerPostViewModel
                {
                    CustomerAccount = customerAccount,
                };
                return(View("TellerPostForm", viewModel));
            }
            //compute transaction
            var postEntry = _context.PostEntry(tellerPost);

            if (postEntry == "Success")
            {
                tellerPost.PostedAt = DateTime.Now;
                _context.Save(tellerPost);
                TempData["Success"] = "Post Successful";
            }
            else
            {
                TempData["error"] = postEntry;

                var viewModel = new TellerPostViewModel
                {
                    CustomerAccount = customerAccount,
                };
                return(View("TellerPostForm", viewModel));
            }
            return(RedirectToAction("Index"));
        }