public async Task <bool> AddToPlaylist(string playlistID, MediaLink media) { //set order value, new content should be added at the end double?orderValue; var playlistsContent = await _featuredPlaylistDataService.GetPlaylistContent(new List <string>() { playlistID }); if (playlistsContent.Any(pc => pc.Order != null)) { orderValue = playlistsContent.Max(pc => pc.Order); orderValue++; } else { orderValue = playlistsContent.Count + 1; } PlaylistContent playlistContent = new PlaylistContent { ContentId = media.ID, PlasylistId = playlistID, Name = media.Name, Order = orderValue }; var result = await _featuredPlaylistDataService.SavePlaylistContent(playlistContent); var returnValue = result != null; if (returnValue) { await SyncUpNewPlaylist(true); } return(returnValue); }
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; } })); }
public MediaLink(DocumentInfo documentInfo, PlaylistContent playlistContent) : this(documentInfo) { Order = playlistContent.Order; JunctionID = playlistContent.Id; }