public async Task <IActionResult> Edit(int id, [Bind("PaymentDetails,CardOwnerName,CardNumber,ExpirationDate,SecurityCode")] PaymentDetail paymentDetail)
        {
            if (id != paymentDetail.PaymentDetails)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paymentDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentDetailExists(paymentDetail.PaymentDetails))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(paymentDetail));
        }
        internal static void UpdateTicketsFromEventTicket(EventTicket eventTicket, PaymentContext context)
        {
            // get the list of all Tickets associated with this record
            var tickets = context.Ticket.Where(t => t.EventTicketId == eventTicket.EvenTicketId && t.StateCode == 0);

            // update their amount fields
            foreach (var curTicket in tickets)
            {
                curTicket.AmountNonreceiptable = eventTicket.AmountNonReceiptable ?? 0;
                curTicket.AmountReceipted      = eventTicket.AmountReceipted ?? 0;
                curTicket.SyncDate             = null;
                context.Update(curTicket);
            }

            context.SaveChanges();
        }
        internal static void UpdateProductsFromEventProduct(EventProduct eventProduct, PaymentContext context)
        {
            // get the list of all Products associated with this record
            var products = context.Product.Where(p => p.EventProductId == eventProduct.EventProductId && p.StateCode == 0).ToList();

            // update their amount fields
            foreach (var curProduct in products)
            {
                curProduct.AmountNonreceiptable = eventProduct.AmountNonReceiptable ?? 0;
                curProduct.AmountReceipted      = eventProduct.AmountReceipted ?? 0;
                curProduct.SyncDate             = null;
                context.Update(curProduct);
            }

            context.SaveChanges();
        }
        internal static void UpdateSponsorshipsFromEventSponsorship(EventSponsorship eventSponsorship,
                                                                    PaymentContext context)
        {
            // get the list of all Sponsorships associated with this record
            var sponsorships =
                context.Sponsorship.Where(s => s.EventSponsorshipId == eventSponsorship.EventSponsorshipId && s.StateCode == 0).ToList();

            // update their amount fields
            foreach (var curSponsorship in sponsorships)
            {
                curSponsorship.AmountNonreceiptable = eventSponsorship.AmountNonReceiptable ?? 0;
                curSponsorship.AmountReceipted      = eventSponsorship.AmountReceipted ?? 0;
                curSponsorship.SyncDate             = null;
                context.Update(curSponsorship);
            }

            context.SaveChanges();
        }
        internal static void UpdateEventPackage(EventPackage eventPackage, PaymentContext context)
        {
            // get all the Tickets, Products and Sponsorships associated with the Event Package
            var tickets = context.Ticket.Where(t => t.EventPackageId == eventPackage.EventPackageId);

            Console.WriteLine("Found " + tickets.Count() + " Tickets associated with the Event Package");
            var products = context.Product.Where(p => p.EventPackageId == eventPackage.EventPackageId);

            Console.WriteLine("Found " + products.Count() + " Products associated with the Event Package");
            var sponsorships =
                context.Sponsorship.Where(s => s.EventPackageId == eventPackage.EventPackageId);

            Console.WriteLine("Found " + sponsorships.Count() + " Sponsorships associated with the Event Package");

            decimal ticketNonReceiptable       = 0;
            decimal productNonReceiptable      = 0;
            decimal sponsorshipNonpReceiptable = 0;
            decimal totalNonReceiptable        = 0;
            var     eventPackageTotalAmount    = eventPackage.Amount;

            ticketNonReceiptable       = tickets.Sum(t => t.AmountNonreceiptable ?? 0);
            productNonReceiptable      = products.Sum(p => p.AmountNonreceiptable ?? 0);
            sponsorshipNonpReceiptable = sponsorships.Sum(s => s.AmountNonreceiptable ?? 0);
            Console.WriteLine("Sum of Ticket Amount Non-Receipetable: " + ticketNonReceiptable);
            Console.WriteLine("Sum of Product Amount ReceiNon-Receipetablepted: " + productNonReceiptable);
            Console.WriteLine("Sum of Sponsorship Amount Non-Receipetable: " + sponsorshipNonpReceiptable);
            totalNonReceiptable = ticketNonReceiptable + productNonReceiptable + sponsorshipNonpReceiptable;
            Console.WriteLine("Total Amount Non-Receipetable:" + totalNonReceiptable);


            eventPackage.AmountNonReceiptable = totalNonReceiptable;
            eventPackage.AmountReceipted      = eventPackageTotalAmount - totalNonReceiptable;
            eventPackage.SyncDate             = null;
            context.Update(eventPackage);
            context.SaveChanges();
            Console.WriteLine("Updated Event Package: " + eventPackage.EventPackageId);
        }