public async Task <IActionResult> OnPostAddPayment(int?billInstanceID, int?billPayID)
        {
            if (billPayID == null || billInstanceID == null)
            {
                return(NotFound());
            }

            //Ensure parameters belong to current user
            BillInstance instance = await _billService.GetBillInstanceAsync((int)billInstanceID);

            if (instance == null)
            {
                return(NotFound());
            }

            SimpleBillPay.Models.BillPay billPay = await _billPayService.GetByIdAsync((int)billPayID);

            if (billPay == null)
            {
                return(NotFound());
            }

            //Add new payment with this bill instance and attached to this bill pay
            Payment payment = new Payment();

            payment.BillInstance = instance;

            payment.Amount        = (instance.Amount - instance.Payments.Sum(p => p.Amount));
            payment.PaymentDate   = billPay.BillPayDate;
            payment.DateConfirmed = null;
            payment.BillPay       = billPay;

            await _paymentService.AddAsync(payment);

            //Call get method to rebuild page
            return(Redirect("./Edit?id=" + billPayID.ToString()));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            BillPay = await _billPayService.GetByIdAsync((int)id);

            if (BillPay == null)
            {
                return(NotFound());
            }
            return(Page());
        }