public void DeleteLead(Domain.Lead lead) { var temp = fakeLeads.ToList(); temp.RemoveAll(row => row.LeadId == lead.LeadId); fakeLeads = temp; }
public void DeleteLead(Domain.Lead lead) { using (Npgsql.NpgsqlConnection conn = new Npgsql.NpgsqlConnection(Infrastructure.ConfigReader.ConnectionString.ToString())) { conn.Open(); using (Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(LeadDeleteQuery, conn)) { command.Parameters.Add(new Npgsql.NpgsqlParameter("leadid", NpgsqlTypes.NpgsqlDbType.Integer)); command.Prepare(); command.Parameters[0].Value = lead.LeadId; int rowsAffected = command.ExecuteNonQuery(); } } }
public void SaveLead(Domain.Lead lead) { // If it's a new lead, just add it to the list if (lead.LeadId == 0) { lead.LeadId = counter; counter += 1; fakeLeads.Add(lead); } else if (fakeLeads.Count(row => row.LeadId == lead.LeadId) == 1) { //This is an update. Remove old one, insert new one DeleteLead(lead); fakeLeads.Add(lead); } }
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); } }