Home360Aristotle 360 APICreating New Individual With Email Information (Sample)

93.5. Creating New Individual With Email Information (Sample)

getIndividualInfoWebService.getIndividualInformationWebService wsIndInfo = new API_Test.getIndividualInfoWebService.getIndividualInformationWebService();

string newIndGUID = Guid.NewGuid().ToString();
DataSet dsInd = wsIndInfo.getDetail(newIndGUID, username, password);

// check if it passed authentication/authorization stage
if (dsInd.Tables["Credentials"] != null)
{
 if (dsInd.Tables["Credentials"].Rows[0]["isvalid"].ToString().ToUpper() == "FALSE")
 {
  lblMsg.Text = dsInd.Tables["Credentials"].Rows[0][3].ToString();
  return;
 }
}

// make sure there were no errors that occured
// you should do the same thing after setDetail method gets called
if (dsInd.Tables["Error"].Rows.Count > 0)
{
 lblMsg.Text = dsInd.Tables["Error"].Rows[0][0].ToString();
 return;
}

// insert a new row and modify the basic information
DataRow drNewInd = dsInd.Tables["std_Individual"].NewRow();
drNewInd["ind_GUID"] = newIndGUID;
dsInd.Tables["std_Individual"].Rows.Add(drNewInd);
dsInd.Tables["std_Individual"].Rows[0]["ind_SourceID"] = "123";
dsInd.Tables["std_Individual"].Rows[0]["ind_Salutation1"] = "";
dsInd.Tables["std_Individual"].Rows[0]["ind_FirstName"] = "James";
dsInd.Tables["std_Individual"].Rows[0]["ind_LastName"] = "Test";
dsInd.Tables["std_Individual"].Rows[0]["ind_MiddleName"] = "";
dsInd.Tables["std_Individual"].Rows[0]["ind_Title"] = "";
dsInd.Tables["std_Individual"].Rows[0]["ind_VoterId"] = "";
dsInd.Tables["std_Individual"].Rows[0]["ind_MailName"] = "James Test";

// get email type - this will get a default one
DataSet dsEmailType = wsIndInfo.getList("std_IndividualEmailType", username, password);
DataRow[] defaultEmail = dsEmailType.Tables["std_IndividualEmailType"].Select("emt_Default=1");
string defaultEmailType = defaultEmail[0]["emt_Text"].ToString();
string defaultEmailTypeGUID = defaultEmail[0]["emt_GUID"].ToString();

// add email record
DataRow drEmail = dsInd.Tables["rtb_IndividualeMail"].NewRow();
drEmail["ema_GUID"] = System.Guid.NewGuid().ToString();  //add new GuID
drEmail["ema_ind_GUID"] = drNewInd["ind_GUID"].ToString(); //set Individual GUID
drEmail["ema_Email"] = "something@aristotle.com";           //set email address text
drEmail["ema_emt_GUID"] = defaultEmailTypeGUID;    //set emailtype guid to default 
drEmail["emt_Text"] = defaultEmailType;      //set emailtype to default 
drEmail["ema_Deleted"] = 0;
drEmail["ema_Default"] = 1;
dsInd.Tables["rtb_IndividualeMail"].Rows.Add(drEmail);

// same as above - you should check for the error table
// set individual data webservice
setIndividualInfoWebService.setIndividualInformationWebService wsSetInd = new API_Test.setIndividualInfoWebService.setIndividualInformationWebService();
wsSetInd.setDetail(dsInd, username, password);

This page was: Helpful | Not Helpful