コード例 #1
0
        private static Lead populateLeadFromDB(Npgsql.NpgsqlDataReader dr)
        {
            Lead newUser = new Lead();

            newUser.LeadId                = Helper.ConvertFromDBVal <int>(dr[0]);
            newUser.CompanyName           = dr[1].ToString();
            newUser.Contact1Title         = dr[2].ToString();
            newUser.Contact1FirstName     = dr[3].ToString();
            newUser.Contact2Title         = dr[4].ToString();
            newUser.Contact2FirstName     = dr[5].ToString();
            newUser.PrimaryPhoneNumber    = dr[6].ToString();
            newUser.AddtionalPhoneNumber  = dr[7].ToString();
            newUser.NumberToCall          = Helper.ConvertFromDBVal <int>(dr[8]);
            newUser.FaxNumber             = dr[9].ToString();
            newUser.PrimaryEmailAddress   = dr[10].ToString();
            newUser.AdditonalEmailAddress = dr[11].ToString();
            newUser.WebsiteLink           = dr[12].ToString();
            newUser.StreetAddress1        = dr[13].ToString();
            newUser.StreetAddress2        = dr[14].ToString();
            newUser.City             = dr[15].ToString();
            newUser.State            = dr[16].ToString();
            newUser.ZipCode          = dr[17].ToString();
            newUser.ZoneNumber       = Helper.ConvertFromDBVal <int>(dr[18]);
            newUser.Status           = dr[19].ToString();
            newUser.AssignedSAUserId = Helper.ConvertFromDBVal <int>(dr[20]);
            newUser.CallbackDate     = Helper.ConvertFromDBVal <DateTime>(dr[21]);
            newUser.IgnoredDate      = Helper.DateConvertFromDBVal <DateTime>(dr[22]);
            newUser.AssignedAAUserId = Helper.ConvertFromDBVal <int>(dr[23]);

            newUser.Contact1LastName    = dr[24].ToString();
            newUser.Contact2LastName    = dr[25].ToString();
            newUser.Suppressed          = Helper.ConvertFromDBVal <Boolean>(dr[26]);
            newUser.Ignored             = Helper.ConvertFromDBVal <Boolean>(dr[27]);
            newUser.DateTimeImported    = Helper.ConvertFromDBVal <DateTime>(dr[28]);
            newUser.Reassigned          = Helper.ConvertFromDBVal <Boolean>(dr[29]);
            newUser.PrimaryPhoneChecked = Helper.ConvertFromDBVal <Boolean>(dr[30]);

            PGUploadedfileRepository upFile = new PGUploadedfileRepository();

            //newUser.StatementFile = upFile.UploadedFiles.Single(row => row.leadID == newUser.LeadId);
            newUser.StatementFiles.AddRange(upFile.GetFileByLeadId(newUser.LeadId));

            return(newUser);
        }
コード例 #2
0
        //To save account(s) to DB
        public void SaveAccounts(Domain.Account account)
        {
            string query;
            bool   isUpdate = false;

            // Want to know right off the bat if we're doing a insert or update
            if (account.AccountId > 0)
            {
                query    = AccountUpdateQuery;
                isUpdate = true;
            }
            else
            {
                query = AccountInsertQuery;
            }

            using (Npgsql.NpgsqlConnection conn = new Npgsql.NpgsqlConnection(Infrastructure.ConfigReader.ConnectionString.ToString()))
            {
                conn.Open();
                using (Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(query, conn))
                {
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("merchantid", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("accountname", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("aacreator", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("assignedsalesrep", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("salesrepnumber", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("officenumber", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("status", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("accountapprovaldate", NpgsqlTypes.NpgsqlDbType.Timestamp));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("annualfee", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("estimatedmonthlyvolume", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("ht", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("hmv", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("platform", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("vendor", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("vip", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("mbp", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("freesupplies", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("pcirefund", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("mailingstreet", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("mailingcity", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("mailingstate", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("mailingzipcode", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("dbastreet", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("dbacity", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("dbastate", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("dbazipcode", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primaryphone", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("secondaryphone", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("faxnumber", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primaryemail", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("secondaryemail", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("website", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("credit", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("debit", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("arb", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("cim", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("ip", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("giftcardprocessor", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("secur_chex", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("software", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("ecommerce", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primaryterminal", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primaryterminalowner", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primaryterminalquantity", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("secondaryterminal", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("secondaryterminalowner", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("secondaryterminalquantity", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("checkequipment", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("checkequipmentowner", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("checkequipmentquantity", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primarypinpad", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primarypinpadowner", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primarypinpadquantity", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("secondarypinpad", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("secondarypinpadowner", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("secondarypinpadquantity", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("printer", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("priterowner", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("description", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("uploadfiles", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("parentlead", NpgsqlTypes.NpgsqlDbType.Integer));



                    if (isUpdate)
                    {
                        command.Parameters.Add(new Npgsql.NpgsqlParameter("accountid", NpgsqlTypes.NpgsqlDbType.Integer));
                    }

                    command.Prepare();

                    command.Parameters[0].Value  = account.MerchantId;
                    command.Parameters[1].Value  = account.AccountName;
                    command.Parameters[2].Value  = account.AACreator;
                    command.Parameters[3].Value  = account.AssignedSalesRep;
                    command.Parameters[4].Value  = account.SalesRepNumber;
                    command.Parameters[5].Value  = account.OfficeNumber;
                    command.Parameters[6].Value  = account.Status;
                    command.Parameters[7].Value  = account.AccountApprovalDate;
                    command.Parameters[8].Value  = account.AnnualFee;
                    command.Parameters[9].Value  = account.EstimatedMonthlyVolume;
                    command.Parameters[10].Value = account.HT;
                    command.Parameters[11].Value = account.HMV;
                    command.Parameters[12].Value = account.Platform;
                    command.Parameters[13].Value = account.Vendor;
                    command.Parameters[14].Value = account.VIP;
                    command.Parameters[15].Value = account.MBP;
                    command.Parameters[16].Value = account.FreeSupplies;
                    command.Parameters[17].Value = account.PCIRefund;
                    command.Parameters[18].Value = account.MailingStreet;
                    command.Parameters[19].Value = account.MailingCity;
                    command.Parameters[20].Value = account.MailingState;
                    command.Parameters[21].Value = account.MailingZipcode;
                    command.Parameters[22].Value = account.DBAStreet;
                    command.Parameters[23].Value = account.DBACity;
                    command.Parameters[24].Value = account.DBAState;
                    command.Parameters[25].Value = account.DBAZipcode;
                    command.Parameters[26].Value = account.PrimaryPhone;
                    command.Parameters[27].Value = account.SecondaryPhone;
                    command.Parameters[28].Value = account.FaxNumber;
                    command.Parameters[29].Value = account.PrimaryEmail;
                    command.Parameters[30].Value = account.SecondaryEmail;
                    command.Parameters[31].Value = account.Website;
                    command.Parameters[32].Value = account.Credit;
                    command.Parameters[33].Value = account.Debit;
                    command.Parameters[34].Value = account.ARB;
                    command.Parameters[35].Value = account.CIM;
                    command.Parameters[36].Value = account.IP;
                    command.Parameters[37].Value = account.GiftCardProcessor;
                    command.Parameters[38].Value = account.Secur_Chex;
                    command.Parameters[39].Value = account.Software;
                    command.Parameters[40].Value = account.ECommerace;
                    command.Parameters[41].Value = account.PrimaryTerminal;
                    command.Parameters[42].Value = account.PrimaryTerminalOwner;
                    command.Parameters[43].Value = account.PrimaryTerminalQuantity;
                    command.Parameters[44].Value = account.SecondaryTerminal;
                    command.Parameters[45].Value = account.SecondaryTerminalOwner;
                    command.Parameters[46].Value = account.SecondaryTerminalQuantity;
                    command.Parameters[47].Value = account.CheckEquipment;
                    command.Parameters[48].Value = account.CheckEquipmentOwner;
                    command.Parameters[49].Value = account.CheckEquipmentQuantity;
                    command.Parameters[50].Value = account.PrimaryPINpad;
                    command.Parameters[51].Value = account.PrimaryPINpadOwner;
                    command.Parameters[52].Value = account.PrimaryPINpadQuantity;
                    command.Parameters[53].Value = account.SecondaryPINpad;
                    command.Parameters[54].Value = account.SecondaryPINpadOwner;
                    command.Parameters[55].Value = account.SecondaryPINpadQuantity;
                    command.Parameters[56].Value = account.Printer;
                    command.Parameters[57].Value = account.PrinterOwner;
                    command.Parameters[58].Value = account.Description;
                    command.Parameters[59].Value = account.UploadedFiles;
                    command.Parameters[60].Value = account.ParentLead;



                    if (isUpdate)
                    {
                        command.Parameters[61].Value = account.AccountId;
                    }

                    int rowsAffected = command.ExecuteNonQuery();
                }
            }
            if (account.NewFilePath != null && account.NewFilePath != string.Empty)
            {
                PGUploadedfileRepository upFile = new PGUploadedfileRepository();
                upFile.InsertAccountFile(account.AccountId, account.NewFilePath);
            }
        }
コード例 #3
0
        private static Account populateAccountFromDB(Npgsql.NpgsqlDataReader dr)
        {
            Account newUser = new Account();

            newUser.AccountId              = Helper.ConvertFromDBVal <int>(dr[0]);
            newUser.MerchantId             = dr[1].ToString();
            newUser.AccountName            = dr[2].ToString();
            newUser.AACreator              = Helper.ConvertFromDBVal <int>(dr[3]);
            newUser.AssignedSalesRep       = Helper.ConvertFromDBVal <int>(dr[4]);
            newUser.SalesRepNumber         = dr[5].ToString();
            newUser.OfficeNumber           = dr[6].ToString();
            newUser.Status                 = dr[7].ToString();
            newUser.AccountApprovalDate    = Helper.ConvertFromDBVal <DateTime>(dr[8]);
            newUser.AnnualFee              = Helper.ConvertFromDBVal <Boolean>(dr[9]);
            newUser.EstimatedMonthlyVolume = dr[10].ToString();
            newUser.HT             = dr[11].ToString();
            newUser.HMV            = dr[12].ToString();
            newUser.Platform       = dr[13].ToString();
            newUser.Vendor         = dr[14].ToString();
            newUser.VIP            = Helper.ConvertFromDBVal <Boolean>(dr[15]);
            newUser.MBP            = Helper.ConvertFromDBVal <Boolean>(dr[16]);
            newUser.FreeSupplies   = Helper.ConvertFromDBVal <Boolean>(dr[17]);
            newUser.PCIRefund      = Helper.ConvertFromDBVal <Boolean>(dr[18]);
            newUser.MailingStreet  = dr[19].ToString();
            newUser.MailingCity    = dr[20].ToString();
            newUser.MailingState   = dr[21].ToString();
            newUser.MailingZipcode = dr[22].ToString();
            newUser.DBAStreet      = dr[23].ToString();
            newUser.DBACity        = dr[24].ToString();
            newUser.DBAState       = dr[25].ToString();
            newUser.DBAZipcode     = dr[26].ToString();
            newUser.PrimaryPhone   = dr[27].ToString();
            newUser.SecondaryPhone = dr[28].ToString();
            newUser.FaxNumber      = dr[29].ToString();
            newUser.PrimaryEmail   = dr[30].ToString();
            newUser.SecondaryEmail = dr[31].ToString();
            newUser.Website        = dr[32].ToString();

            newUser.Credit                    = Helper.ConvertFromDBVal <Boolean>(dr[33]);
            newUser.Debit                     = Helper.ConvertFromDBVal <Boolean>(dr[34]);
            newUser.ARB                       = Helper.ConvertFromDBVal <Boolean>(dr[35]);
            newUser.CIM                       = Helper.ConvertFromDBVal <Boolean>(dr[36]);
            newUser.IP                        = Helper.ConvertFromDBVal <Boolean>(dr[37]);
            newUser.GiftCardProcessor         = dr[38].ToString();
            newUser.Secur_Chex                = dr[39].ToString();
            newUser.Software                  = dr[40].ToString();
            newUser.ECommerace                = dr[41].ToString();
            newUser.PrimaryTerminal           = Helper.ConvertFromDBVal <int>(dr[42]);
            newUser.PrimaryTerminalOwner      = dr[43].ToString();
            newUser.PrimaryTerminalQuantity   = Helper.ConvertFromDBVal <int>(dr[44]);
            newUser.SecondaryTerminal         = Helper.ConvertFromDBVal <int>(dr[45]);
            newUser.SecondaryTerminalOwner    = dr[46].ToString();
            newUser.SecondaryTerminalQuantity = Helper.ConvertFromDBVal <int>(dr[47]);
            newUser.CheckEquipment            = Helper.ConvertFromDBVal <int>(dr[48]);
            newUser.CheckEquipmentOwner       = dr[49].ToString();
            newUser.CheckEquipmentQuantity    = Helper.ConvertFromDBVal <int>(dr[50]);
            newUser.PrimaryPINpad             = Helper.ConvertFromDBVal <int>(dr[51]);
            newUser.PrimaryPINpadOwner        = dr[52].ToString();
            newUser.PrimaryPINpadQuantity     = Helper.ConvertFromDBVal <int>(dr[53]);
            newUser.SecondaryPINpad           = Helper.ConvertFromDBVal <int>(dr[54]);
            newUser.SecondaryPINpadOwner      = dr[55].ToString();
            newUser.SecondaryPINpadQuantity   = Helper.ConvertFromDBVal <int>(dr[56]);
            newUser.Printer                   = ConvertFromDBVal <string>(dr[57]);
            newUser.PrinterOwner              = ConvertFromDBVal <string>(dr[58]);
            newUser.Description               = dr[59].ToString();
            newUser.UploadedFiles             = Helper.ConvertFromDBVal <int>(dr[60]);
            newUser.ParentLead                = Helper.ConvertFromDBVal <int>(dr[61]);

            PGUploadedfileRepository upFile = new PGUploadedfileRepository();

            newUser.StatementFiles.AddRange(upFile.GetFileByAccountId(newUser.AccountId));

            return(newUser);
        }
コード例 #4
0
        public void SaveLead(Domain.Lead lead)
        {
            string query;
            bool   isUpdate = false;

            // Want to know right off the bat if we're doing a insert or update
            if (lead.LeadId > 0)
            {
                query    = LeadUpdateQuery;
                isUpdate = true;
            }
            else
            {
                query = LeadInsertQuery;
            }

            using (Npgsql.NpgsqlConnection conn = new Npgsql.NpgsqlConnection(Infrastructure.ConfigReader.ConnectionString.ToString()))
            {
                conn.Open();
                using (Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(query, conn))
                {
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("companyname", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("contact1title", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("contact1firstname", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("contact2title", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("contact2firstname", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primaryphonenumber", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("additionalphonenumber", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("numbertocall", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("faxnumber", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primaryemailaddress", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("additionalemailaddress", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("websitelink", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("streetaddress1", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("streetaddress2", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("city", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("state", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("zipcode", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("zonenumber", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("status", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("assignedsauserid", NpgsqlTypes.NpgsqlDbType.Integer));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("callbackdate", NpgsqlTypes.NpgsqlDbType.Date));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("ignoreddate", NpgsqlTypes.NpgsqlDbType.Date));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("assignedaauserid", NpgsqlTypes.NpgsqlDbType.Integer));

                    command.Parameters.Add(new Npgsql.NpgsqlParameter("contact1lastname", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("contact2lastname", NpgsqlTypes.NpgsqlDbType.Text));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("suppressed", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("ignored", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("dateimported", NpgsqlTypes.NpgsqlDbType.Timestamp));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("reassigned", NpgsqlTypes.NpgsqlDbType.Boolean));
                    command.Parameters.Add(new Npgsql.NpgsqlParameter("primaryphonechecked", NpgsqlTypes.NpgsqlDbType.Boolean));

                    if (isUpdate)
                    {
                        command.Parameters.Add(new Npgsql.NpgsqlParameter("leadid", NpgsqlTypes.NpgsqlDbType.Integer));
                    }

                    command.Prepare();

                    command.Parameters[0].Value  = lead.CompanyName;
                    command.Parameters[1].Value  = lead.Contact1Title;
                    command.Parameters[2].Value  = lead.Contact1FirstName;
                    command.Parameters[3].Value  = lead.Contact2Title;
                    command.Parameters[4].Value  = lead.Contact2FirstName;
                    command.Parameters[5].Value  = lead.PrimaryPhoneNumber;
                    command.Parameters[6].Value  = lead.AddtionalPhoneNumber;
                    command.Parameters[7].Value  = lead.NumberToCall;
                    command.Parameters[8].Value  = lead.FaxNumber;
                    command.Parameters[9].Value  = lead.PrimaryEmailAddress;
                    command.Parameters[10].Value = lead.AdditonalEmailAddress;
                    command.Parameters[11].Value = lead.WebsiteLink;
                    command.Parameters[12].Value = lead.StreetAddress1;
                    command.Parameters[13].Value = lead.StreetAddress2;
                    command.Parameters[14].Value = lead.City;
                    command.Parameters[15].Value = lead.State;
                    command.Parameters[16].Value = lead.ZipCode;
                    command.Parameters[17].Value = lead.ZoneNumber;
                    command.Parameters[18].Value = lead.Status;
                    command.Parameters[19].Value = lead.AssignedSAUserId;
                    command.Parameters[20].Value = lead.CallbackDate;
                    command.Parameters[21].Value = lead.IgnoredDate;
                    command.Parameters[22].Value = lead.AssignedAAUserId;

                    command.Parameters[23].Value = lead.Contact1LastName;
                    command.Parameters[24].Value = lead.Contact2LastName;
                    command.Parameters[25].Value = lead.Suppressed;

                    command.Parameters[26].Value = lead.Ignored;
                    command.Parameters[27].Value = lead.DateTimeImported;
                    command.Parameters[28].Value = lead.Reassigned;
                    command.Parameters[29].Value = lead.PrimaryPhoneChecked;


                    if (isUpdate)
                    {
                        command.Parameters[30].Value = lead.LeadId;
                    }

                    int rowsAffected = command.ExecuteNonQuery();
                }
            }

            if (lead.NewFilePath != null && lead.NewFilePath != string.Empty)
            {
                PGUploadedfileRepository upFile = new PGUploadedfileRepository();
                upFile.InsertLeadFile(lead.LeadId, lead.NewFilePath);
            }
        }