public PaymentQuery getUserPayment(long id)
        {
            try
            {
                using (conferenceadminContext context = new conferenceadminContext())
                {
                    var paymentInfo = (from s in context.paymentbills
                                       from sp in context.registrations
                                       where s.paymentID == sp.paymentID && s.deleted == false && sp.userID == id && s.completed == true
                                       select new PaymentQuery
                                       {
                                           paymentBillID = s.paymentBillID,
                                           date = s.date,
                                           affiliationName = sp.user.affiliationName,
                                           transactionid = s.transactionid,
                                           AmountPaid = s.AmountPaid,
                                           methodOfPayment = s.methodOfPayment,
                                           firstName = s.firstName,
                                           lastName = s.lastName,
                                           email = s.email,
                                           tandemID = s.tandemID,
                                           batchID = s.batchID,
                                           userFirstName = sp.user.firstName,
                                           userLastName = sp.user.lastName,
                                           type = sp.user.usertype.userTypeName,
                                           description = "User Registration"

                                       }).FirstOrDefault();

                    if (paymentInfo == null)
                    {

                        paymentInfo = (from r in context.paymentcomplementaries
                                       join p in context.complementarykeys on r.complementaryKeyID equals p.complementarykeyID
                                       join pay in context.payments on r.paymentID equals pay.paymentID
                                       join y in context.sponsor2 on p.sponsorID2 equals y.sponsorID
                                       join x in context.registrations on r.paymentID equals x.paymentID
                                       where id == x.userID && x.deleted == false && r.deleted == false && p.deleted == false && pay.deleted == false
                                       select new PaymentQuery
                                       {
                                           paymentBillID = r.paymentcomplementaryID,
                                           complementaryKey = p.key,
                                           date = (DateTime)pay.creationDate,
                                           affiliationName = x.user.affiliationName,
                                           transactionid = "N/A",
                                           AmountPaid = 0,
                                           methodOfPayment = "Complementary Key",
                                           userFirstName = x.user.firstName,
                                           userLastName = x.user.lastName,
                                           email = x.user.membership.email,
                                           tandemID = "N/A",
                                           batchID = "N/A",
                                           firstName = y.user.firstName,
                                           lastName = y.user.lastName,
                                           description = "User Registration",
                                           type = x.user.usertype.userTypeName,

                                       }).FirstOrDefault();

                    }
                    if (paymentInfo == null)
                    {
                        PaymentQuery error = new PaymentQuery();
                        error.paymentBillID = -1;///not found
                        return error;
                    }
                    else { return paymentInfo; }
                }

            }
            catch (Exception ex)
            {
                Console.Write("PaymetnManager.getPaymentReceiptInfo error " + ex);

                return null;
            }
        }
        public PaymentQuery getPayment(long id)
        {
            try
            {
                using (conferenceadminContext context = new conferenceadminContext())
                {
                    var paymentInfo = (from s in context.paymentbills
                                       from sp in context.sponsor2
                                       where s.paymentBillID == id && s.deleted == false && sp.paymentID == s.paymentID && s.completed == true
                                       select new PaymentQuery
                                       {
                                           paymentBillID = s.paymentBillID,
                                           date = s.date,
                                           affiliationName = sp.user.affiliationName,
                                           transactionid = s.transactionid,
                                           AmountPaid = s.AmountPaid,
                                           methodOfPayment = s.methodOfPayment,
                                           firstName = s.firstName,
                                           lastName = s.lastName,
                                           email = s.email,
                                           tandemID = s.tandemID,
                                           batchID = s.batchID,
                                           userFirstName = sp.user.firstName,
                                           userLastName = sp.user.lastName,
                                           type = sp.sponsortype1.name,
                                           description = "Sponsor Donation"

                                       }).FirstOrDefault();

                    if (paymentInfo == null)
                    {
                        paymentInfo = (from s in context.paymentbills
                                       from r in context.registrations
                                       where s.paymentBillID == id && s.deleted == false && r.paymentID == s.paymentID && s.completed == true
                                       select new PaymentQuery
                                       {
                                           paymentBillID = s.paymentBillID,
                                           date = (DateTime)s.payment.creationDate,
                                           transactionid = s.transactionid,
                                           AmountPaid = s.AmountPaid,
                                           methodOfPayment = s.methodOfPayment,
                                           firstName = s.firstName,
                                           lastName = s.lastName,
                                           email = s.email,
                                           tandemID = s.tandemID,
                                           batchID = s.batchID,
                                           userFirstName = r.user.firstName,
                                           userLastName = r.user.lastName,
                                           affiliationName = r.user.affiliationName,
                                           type = r.user.usertype.userTypeName,
                                           description = "User Registration."
                                       }).FirstOrDefault();
                    }

                    if (paymentInfo == null)
                    {
                        PaymentQuery error = new PaymentQuery();
                        error.paymentBillID = -1;//notify not found
                        return error;
                    }
                    return paymentInfo;
                }

            }
            catch (Exception ex)
            {
                Console.Write("PaymetnManager.getPaymentReceiptInfo error " + ex);
                return null;
            }
        }