// GET: /<controller>/ public IActionResult Index(int discard = 0) { if (discard == 1) { BillPaySessionKey.Clear(HttpContext.Session); } var billPays = BPMgr.GetBillPaysOfCustomer(CustomerID); return(View(billPays)); }
public IActionResult Cancel() { var viewModel = BillPaySessionKey.GetEditViewModelFromSession(HttpContext.Session); if (viewModel.BillPayEditOp == BillPayEditOp.Create) { return(RedirectToAction("Create", "BillPay")); } return(RedirectToAction("Edit", "BillPay")); }
public async Task <IActionResult> Index([FromForm] int payeeID) { var payee = await PMgr.GetPayeeAsync(payeeID); var viewModel = BillPaySessionKey.GetEditViewModelFromSession(HttpContext.Session); viewModel.Payee = payee; BillPaySessionKey.SetEditViewModelToSession(viewModel, HttpContext.Session); if (viewModel.BillPayEditOp == BillPayEditOp.Create) { return(RedirectToAction("Create", "BillPay")); } return(RedirectToAction("Edit", "BillPay")); }
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 IActionResult Create([Bind("Name,Address,City,State,PostCode,Phone")] Payee payee) { if (!ModelState.IsValid) { return(View(payee)); } var viewModel = BillPaySessionKey.GetEditViewModelFromSession(HttpContext.Session); viewModel.Payee = payee; BillPaySessionKey.SetEditViewModelToSession(viewModel, HttpContext.Session); if (viewModel.BillPayEditOp == BillPayEditOp.Create) { return(RedirectToAction("Create", "BillPay")); } return(RedirectToAction("Edit", "BillPay")); }
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 IActionResult EditOrCreateToPayeeCreate(BillPayEditViewModel viewModel) { BillPaySessionKey.SetEditViewModelToSession(viewModel, HttpContext.Session); return(RedirectToAction("Create", "Payee")); }