private ZCRMNote GetZCRMNote(JObject noteDetails, ZCRMNote note) { if (note == null) { note = ZCRMNote.GetInstance(parentRecord, Convert.ToInt64(noteDetails.GetValue("id"))); } note.Id = Convert.ToInt64(noteDetails.GetValue("id")); if (noteDetails.GetValue("Note_Title") != null) { note.Title = Convert.ToString(noteDetails.GetValue("Note_Title")); } if (noteDetails.GetValue("Note_Content") != null) { note.Content = Convert.ToString(noteDetails.GetValue("Note_Content")); } JObject createdByObject = (JObject)noteDetails.GetValue("Created_By"); ZCRMUser createdBy = ZCRMUser.GetInstance(Convert.ToInt64(createdByObject.GetValue("id")), Convert.ToString(createdByObject.GetValue("name"))); note.CreatedBy = createdBy; note.CreatedTime = Convert.ToString(noteDetails.GetValue("Created_Time")); JObject modifiedByObject = (JObject)noteDetails.GetValue("Modified_By"); ZCRMUser modifiedBy = ZCRMUser.GetInstance(Convert.ToInt64(modifiedByObject.GetValue("id")), Convert.ToString(modifiedByObject.GetValue("name"))); note.ModifiedBy = modifiedBy; note.ModifiedTime = Convert.ToString(noteDetails.GetValue("Modified_Time")); if (noteDetails.GetValue("Owner") != null) { JObject ownerObject = (JObject)noteDetails.GetValue("Owner"); ZCRMUser owner = ZCRMUser.GetInstance(Convert.ToInt64(ownerObject.GetValue("id")), Convert.ToString(ownerObject.GetValue("name"))); note.NotesOwner = owner; } else { note.NotesOwner = createdBy; } if (noteDetails.GetValue("$attachments") != null) { JArray attachmentsArray = (JArray)noteDetails.GetValue("$attachments"); foreach (JObject attachmentDetails in attachmentsArray) { note.AddAttachment(GetZCRMAttachment(attachmentDetails)); } } return(note); }
private ZCRMNote GetZCRMNote(JObject noteDetails, ZCRMNote note) { if (note == null) { note = ZCRMNote.GetInstance(parentRecord, Convert.ToInt64(noteDetails["id"])); } note.Id = Convert.ToInt64(noteDetails["id"]); if (noteDetails["Note_Title"] != null && noteDetails["Note_Title"].Type != JTokenType.Null) { note.Title = (string)noteDetails["Note_Title"]; } if (noteDetails["Note_Content"] != null && noteDetails["Note_Content"].Type != JTokenType.Null) { note.Content = (string)noteDetails["Note_Content"]; } JObject createdByObject = (JObject)noteDetails["Created_By"]; ZCRMUser createdBy = ZCRMUser.GetInstance(Convert.ToInt64(createdByObject["id"]), (string)createdByObject["name"]); note.CreatedBy = createdBy; note.CreatedTime = CommonUtil.RemoveEscaping((string)JsonConvert.SerializeObject(noteDetails["Created_Time"])); JObject modifiedByObject = (JObject)noteDetails["Modified_By"]; ZCRMUser modifiedBy = ZCRMUser.GetInstance(Convert.ToInt64(modifiedByObject["id"]), (string)modifiedByObject["name"]); note.ModifiedBy = modifiedBy; note.ModifiedTime = CommonUtil.RemoveEscaping((string)JsonConvert.SerializeObject(noteDetails["Modified_Time"])); if (noteDetails["Owner"] != null && noteDetails["Owner"].Type != JTokenType.Null) { JObject ownerObject = (JObject)noteDetails["Owner"]; ZCRMUser owner = ZCRMUser.GetInstance(Convert.ToInt64(ownerObject["id"]), (string)ownerObject["name"]); note.NotesOwner = owner; } else { note.NotesOwner = createdBy; } if (noteDetails["$attachments"] != null && noteDetails["$attachments"].Type != JTokenType.Null) { JArray attachmentsArray = (JArray)noteDetails["$attachments"]; foreach (JObject attachmentDetails in attachmentsArray) { note.AddAttachment(GetZCRMAttachment(attachmentDetails)); } } return(note); }