public Task <PlaylistContent> SavePlaylistContent(PlaylistContent playlistContent) { return(Task <PlaylistContent> .Factory.StartNew(() => { var globalStore = SmartStore.GetGlobalSmartStore(); var record = JObject.FromObject(playlistContent, JsonSerializer.Create(CustomJsonSerializerSettings.Instance.Settings)); //remove data which should not be passed to salesforce record.Property("Id").Remove(); record.Property("ContentId15").Remove(); //set local variable record[Constants.Id] = Guid.NewGuid().ToString();//tmp id, we need it to maintain object relation (Id - it is salesforce tmp id, id - it is internal local id) record[SyncManager.Local] = true; record[SyncManager.LocallyCreated] = true; record[SyncManager.LocallyUpdated] = false; record[SyncManager.LocallyDeleted] = false; //for new record we have to set attributes.type property var prefix = SfdcConfig.CustomerPrefix; var info = playlistContent.GetType().GetTypeInfo().GetCustomAttributes() .SingleOrDefault(t => t is JsonObjectAttribute) as JsonObjectAttribute; if (info != null) { record[Constants.SobjectType] = string.Format(info.Title, prefix); } JObject result = globalStore.Create("PlaylistContent", record, false); if (result != null) { return CustomPrefixJsonConvert.DeserializeObject <PlaylistContent>(result.ToString()); } else { return null; } })); }