public async Task <IActionResult> Modify(int id, [Bind("BillPayID,AccountNumber,PayeeID,Amount,ScheduleDate,Period,Block")] BillPay billPay) { if (id != billPay.BillPayID) { return(NotFound()); } if (HttpContext.Session.GetInt32("Block").Value == 1) { billPay.Block = true; } if (MiscellaneousExtensionUtilities.HasMoreThanTwoDecimalPlaces(billPay.Amount)) { ModelState.AddModelError(nameof(Transaction.Amount), "your should only have 2 decimal places in your amount."); } if (ModelState.IsValid) { try { billPay.ScheduleDate = TimeZoneInfo.ConvertTimeToUtc(billPay.ScheduleDate); _context.Add(billPay); _context.Update(billPay); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BillPayExists(billPay.BillPayID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } List <Period> periods = Enum.GetValues(typeof(Period)).Cast <Period>().ToList(); // set transaction view bag ViewBag.Periods = new SelectList(periods); ViewData["AccountNumber"] = new SelectList(_context.Accounts, "AccountNumber", "AccountNumber", billPay.AccountNumber); ViewData["PayeeID"] = new SelectList(_context.Payees, "PayeeID", "PayeeName", billPay.PayeeID); return(View(billPay)); }
public async Task <IActionResult> Create([Bind("BillPayID,AccountNumber,PayeeID,Amount,ScheduleDate,Period")] BillPay billPay) { if (MiscellaneousExtensionUtilities.HasMoreThanTwoDecimalPlaces(billPay.Amount)) { ModelState.AddModelError(nameof(Transaction.Amount), "your should only have 2 decimal places in your amount."); } if (ModelState.IsValid) { billPay.ScheduleDate = TimeZoneInfo.ConvertTimeToUtc(billPay.ScheduleDate); _context.Add(billPay); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AccountNumber"] = new SelectList(_context.Accounts, "AccountNumber", "AccountNumber", billPay.AccountNumber); ViewData["PayeeID"] = new SelectList(_context.Payees, "PayeeID", "PayeeName", billPay.PayeeID); return(View()); }