Ejemplo n.º 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"));
        }
Ejemplo n.º 2
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"));
        }