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")); }
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)); }
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)); }
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); }
public IActionResult EditOrCreateToPayeeCreate(BillPayEditViewModel viewModel) { BillPaySessionKey.SetEditViewModelToSession(viewModel, HttpContext.Session); return(RedirectToAction("Create", "Payee")); }