public SponsorQuery updateSponsor(SponsorQuery x)
        {
            try
            {
                using (conferenceadminContext context = new conferenceadminContext())
                {
                    var sponsor = (from s in context.sponsor2
                                   from p in context.paymentbills
                                   where s.sponsorID == x.sponsorID && s.paymentID == p.paymentID
                                   select s).FirstOrDefault();
                    if (sponsor != null)
                    {
                        sponsor.user.firstName = x.firstName;
                        sponsor.user.lastName = x.lastName;
                        sponsor.logo = x.logo;
                        sponsor.user.phone = x.phone;
                        sponsor.sponsorType = x.sponsorType;
                        sponsor.user.userFax = x.userFax;
                        sponsor.user.address.city = x.city;
                        sponsor.user.address.country = x.country;
                        sponsor.user.address.state = x.state;
                        sponsor.user.address.zipcode = x.zipcode;
                        sponsor.user.address.line1 = x.line1;
                        sponsor.user.address.line2 = x.line2;
                        sponsor.totalAmount = x.amount;

                        context.SaveChanges();
                        if (x.byAdmin)
                        {
                            var payment = (from p in context.paymentbills
                                           where sponsor.paymentID == p.paymentID
                                           select p).FirstOrDefault();
                            payment.AmountPaid = x.amount;
                            payment.methodOfPayment = x.method;
                            payment.quantity = (int)(x.amount * 100);
                            payment.date = DateTime.Now;
                            context.SaveChanges();

                        }
                    }

                    return x;
                }
            }
            catch (Exception ex)
            {
                Console.Write("SponsorManager.updateSponsor error " + ex);
                return null;
            }
        }
        public SponsorQuery addSponsor(SponsorQuery x)
        {
            try
            {
                using (conferenceadminContext context = new conferenceadminContext())
                {
                    address address = new address();
                    address.city = x.city;
                    address.country = x.country;
                    address.state = x.state;
                    address.zipcode = x.zipcode;
                    address.line1 = x.line1;
                    address.line2 = x.line2;
                    context.addresses.Add(address);
                    context.SaveChanges();

                    user user = new user();
                    user.membershipID = 1;
                    user.firstName = x.firstName;
                    user.lastName = x.lastName;
                    user.userFax = x.userFax;
                    user.phone = x.phone;
                    user.addressID = address.addressID;
                    user.affiliationName = x.company;
                    user.userTypeID = 7;
                    user.deleted = false;
                    context.users.Add(user);
                    context.SaveChanges();

                    payment payment2 = new payment();
                    payment2.paymentTypeID = 1;
                    payment2.deleted = false;
                    payment2.creationDate = DateTime.Now;
                    context.payments.Add(payment2);
                    context.SaveChanges();

                    paymentbill bill = new paymentbill();
                    bill.AmountPaid = (double)x.amount;
                    bill.paymentID = payment2.paymentID;
                    bill.methodOfPayment = x.method;
                    bill.transactionid = x.transactionID;
                    bill.completed = true;
                    bill.quantity = (int)(x.amount * 100);
                    bill.deleted = false;
                    bill.date = DateTime.Now;
                    context.paymentbills.Add(bill);
                    context.SaveChanges();

                    sponsor2 sponsor = new sponsor2();
                    sponsor.userID = user.userID;
                    sponsor.emailInfo = x.email;
                    sponsor.logo = x.logo;
                    sponsor.sponsorType = x.sponsorType;
                    sponsor.totalAmount = x.amount;
                    sponsor.deleted = false;
                    sponsor.byAdmin = true;
                    sponsor.active = true;
                    sponsor.paymentID = payment2.paymentID;

                    context.sponsor2.Add(sponsor);
                    context.SaveChanges();
                    x.sponsorID = sponsor.sponsorID;
                    x.addressID = address.addressID;
                    x.byAdmin = true;
                    return x;
                }

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