public void InsertSubscribers(List <string> productCategories, string firstName, string lastName, string emailAddress) { string subscribersCustomerKey = Properties.Settings.Default.SubscribersCustomerKey.ToString(); //List<ET_DataExtensionColumn> cols = RetrieveAllColumnsOfDataExtension(subscribersCustomerKey); List <KeyValuePair <string, string> > colVals = new List <KeyValuePair <string, string> >(); colVals.Add(new KeyValuePair <string, string>("First_Name", firstName)); colVals.Add(new KeyValuePair <string, string>("Last_Name", lastName)); colVals.Add(new KeyValuePair <string, string>("Email", emailAddress)); PostReturnStatus retStatus = AddDataRowToDataExtension(subscribersCustomerKey, colVals); string optInCustomerKey = Properties.Settings.Default.OptInCustomerKey.ToString(); //List<ET_DataExtensionColumn> cols = RetrieveAllColumnsOfDataExtension(optInCustomerKey); foreach (string productCategory in productCategories) { if (!string.IsNullOrEmpty(productCategory)) { List <KeyValuePair <string, string> > columnValues = new List <KeyValuePair <string, string> >(); columnValues.Add(new KeyValuePair <string, string>("Product_cat", productCategory)); columnValues.Add(new KeyValuePair <string, string>("Email", emailAddress)); PostReturnStatus status = AddDataRowToDataExtension(optInCustomerKey, columnValues); } } }
public PostReturnStatus CreateDataExtension(string name, string customerKey, string primaryColumnName) { ET_DataExtension postDataExtension = new ET_DataExtension(); postDataExtension.AuthStub = _etClient; postDataExtension.Name = name; postDataExtension.CustomerKey = customerKey; ET_DataExtensionColumn nameColumn = new ET_DataExtensionColumn() { Name = primaryColumnName, FieldType = DataExtensionFieldType.Text, IsPrimaryKey = true, MaxLength = 100, IsRequired = true }; postDataExtension.Columns = new ET_DataExtensionColumn[] { nameColumn }; PostReturn postResponse = postDataExtension.Post(); PostReturnStatus status = new PostReturnStatus() { Status = postResponse.Status.ToString(), Message = postResponse.Message.ToString(), Code = postResponse.Code.ToString(), ResultsLength = postResponse.Results.Length }; return(status); }
public void InsertIntoDataExtension(string html, string changeType, string productCategory) { string customerKey = Properties.Settings.Default.NewProductDECustomerKey.ToString(); if (changeType.ToLower() == "update") { customerKey = Properties.Settings.Default.ProductUpdateCustomerKey.ToString(); } //List<ET_DataExtensionColumn> cols = RetrieveAllColumnsOfDataExtension(customerKey); //List<ET_DataExtensionRow> rows = RetrieveRowsOfDataExtension(customerKey, cols); List <KeyValuePair <string, string> > columnValues = new List <KeyValuePair <string, string> >(); columnValues.Add(new KeyValuePair <string, string>("Product_cat", productCategory)); columnValues.Add(new KeyValuePair <string, string>("HTML", html)); PostReturnStatus status = AddDataRowToDataExtension(customerKey, columnValues); }