public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Settlements).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SettlementsExists(Settlements.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #2
0
        public async Task <IActionResult> OnPostAsync(string stripeEmail, string stripeToken, int payment_id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var customers = new CustomerService();
            var charges   = new ChargeService();

            var customer = customers.Create(new CustomerCreateOptions
            {
                Email       = stripeEmail,
                SourceToken = stripeToken
            });

            Payments payments = _context.Payments.Find(payment_id);

            long amount = (long)(payments.Amount * 100);

            var charge = charges.Create(new ChargeCreateOptions
            {
                Amount      = amount,
                Description = "Medical Fee",
                Currency    = "lkr",
                CustomerId  = customer.Id
            });

            payments.IsReceived = 1;

            //var payment = _context.Payments.Where(i => i.Id == Payments.Id).First();
            //payment.IsReceived = 1;
            //_context.SaveChanges();

            //_context.Attach(Payments).State = EntityState.Modified;

            _context.Attach(payments).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PaymentsExists(Payments.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(LocalRedirect("/Payment/Details?id=" + payments.Id.ToString()));

            //return RedirectToRoute("/Payment/Details?id=" + payments.Id.ToString());

            //return RedirectToPage("/Payment/Details?id="+payments.Id.ToString());
        }