private JObject GetFilesAsJSON(ZCRMFiles files) { JObject fileJSON = new JObject(); if (!string.IsNullOrEmpty(files.FileId) && !string.IsNullOrWhiteSpace(files.FileId)) { fileJSON.Add("file_id", files.FileId); } if (!string.IsNullOrEmpty(files.AttachmentId) && !string.IsNullOrWhiteSpace(files.AttachmentId)) { fileJSON.Add("attachment_id", files.AttachmentId); } if (files.Delete) { fileJSON.Add("_delete", null); } return(fileJSON); }
private ZCRMFiles GetZCRMFileObject(JObject file) { ZCRMFiles files = ZCRMFiles.GetInstance(null, null); if (file.ContainsKey("extn") && file["extn"].Type != JTokenType.Null) { files.Extn = file["extn"].ToString(); } if (file.ContainsKey("is_Preview_Available") && file["is_Preview_Available"].Type != JTokenType.Null) { files.IsPreviewAvailable = (bool)file["is_Preview_Available"]; } if (file.ContainsKey("download_Url") && file["download_Url"].Type != JTokenType.Null) { files.DownloadUrl = file["download_Url"].ToString(); } if (file.ContainsKey("delete_Url") && file["delete_Url"].Type != JTokenType.Null) { files.DeleteUrl = file["delete_Url"].ToString(); } if (file.ContainsKey("entity_Id") && file["entity_Id"].Type != JTokenType.Null) { files.EntityId = Convert.ToInt64(file["entity_Id"]); } if (file.ContainsKey("mode") && file["mode"].Type != JTokenType.Null) { files.Mode = file["mode"].ToString(); } if (file.ContainsKey("original_Size_Byte") && file["original_Size_Byte"].Type != JTokenType.Null) { files.OriginalSizeByte = Convert.ToInt64(file["original_Size_Byte"]); } if (file.ContainsKey("preview_Url") && file["preview_Url"].Type != JTokenType.Null) { files.PreviewUrl = file["preview_Url"].ToString(); } if (file.ContainsKey("file_Name") && file["file_Name"].Type != JTokenType.Null) { files.FileName = file["file_Name"].ToString(); } if (file.ContainsKey("file_Id") && file["file_Id"].Type != JTokenType.Null) { files.FileId = file["file_Id"].ToString(); } if (file.ContainsKey("attachment_Id") && file["attachment_Id"].Type != JTokenType.Null) { files.AttachmentId = file["attachment_Id"].ToString(); } if (file.ContainsKey("file_Size") && file["file_Size"].Type != JTokenType.Null) { files.FileSize = file["file_Size"].ToString(); } if (file.ContainsKey("creator_Id") && file["creator_Id"].Type != JTokenType.Null) { files.CreatorId = Convert.ToInt64(file["creator_Id"]); } if (file.ContainsKey("link_Docs") && file["link_Docs"].Type != JTokenType.Null) { files.LinkDocs = (int)file["link_Docs"]; } return(files); }