示例#1
0
        public async Task <IActionResult> Create(BillPayEditViewModel viewModel)
        {
            viewModel.Customer = await CMgr.GetCustomerAsync(CustomerID);

            viewModel.Validate(ModelState);
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var billPay = viewModel.GenerateBillPay();
            await BPMgr.AddToAccountAsync(viewModel.Account, billPay);

            BillPaySessionKey.Clear(HttpContext.Session);
            return(RedirectToAction("Index"));
        }
示例#2
0
        public async Task <IActionResult> Create()
        {
            var viewModel = BillPaySessionKey.GetEditViewModelFromSession(HttpContext.Session);

            if (viewModel == null)
            {
                viewModel = new BillPayEditViewModel
                {
                    ScheduleDate = DateTime.UtcNow
                }
            }
            ;
            viewModel.Customer = await CMgr.GetCustomerAsync(CustomerID);

            viewModel.BillPayEditOp = BillPayEditOp.Create;

            return(View(viewModel));
        }
示例#3
0
        public async Task <IActionResult> Edit(int billPayId)
        {
            var viewModel = BillPaySessionKey.GetEditViewModelFromSession(HttpContext.Session);

            if (viewModel == null)
            {
                var billPay = await BPMgr.GetBillPayAsync(billPayId);

                if (billPay == null)
                {
                    return(NotFound());
                }

                viewModel = BillPayEditViewModel.FromBillPay(billPay);

                HttpContext.Session.SetInt32(BillPaySessionKey.EditBillPayID, billPayId);
            }

            viewModel.Customer = await CMgr.GetCustomerAsync(CustomerID);

            return(View(viewModel));
        }
示例#4
0
        public async Task <IActionResult> Edit(BillPayEditViewModel viewModel)
        {
            int?billPayID = HttpContext.Session.GetInt32(BillPaySessionKey.EditBillPayID);

            if (billPayID == null)
            {
                return(RedirectToAction("Index"));
            }

            viewModel.Customer = await CMgr.GetCustomerAsync(CustomerID);

            viewModel.Validate(ModelState);
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            BillPay billPay = viewModel.GenerateBillPay();
            await BPMgr.UpdateAsync(billPay, billPayID.Value);

            BillPaySessionKey.Clear(HttpContext.Session);
            return(RedirectToAction("Index"));
        }
 public static void SetEditViewModelToSession(BillPayEditViewModel model, ISession session)
 {
     SetToSession(session, EditOrCreate, model);
 }
示例#6
0
        public IActionResult EditOrCreateToPayeeCreate(BillPayEditViewModel viewModel)
        {
            BillPaySessionKey.SetEditViewModelToSession(viewModel, HttpContext.Session);

            return(RedirectToAction("Create", "Payee"));
        }