public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } SimpleBillPay.Models.BillPay billPay = await _billPayService.GetByIdAsync(BillPay.ID); if (billPay == null) { return(NotFound()); } billPay.StartingAmount = BillPay.StartingAmount; billPay.BillPayDate = BillPay.BillPayDate; try { await _billPayService.UpdateBillPayAsync(billPay); } catch (DbUpdateConcurrencyException) { if (!await _billPayService.BillPayExistsAsync(BillPay.ID)) { return(NotFound()); } else { throw; } } catch (DbUpdateException ex) { if (ex.InnerException is MySqlException) { if (((MySqlException)ex.InnerException).Number == 1062) { return(RedirectToPage("./Edit", new { id = BillPay.ID, duplicateDateError = BillPay.BillPayDate.ToString("yyyy-MM-dd") })); } } } return(RedirectToPage("./Edit", new { id = BillPay.ID })); }