Example #1
0
 public async Task AddPlaylistItem(string deviceKey, PlaylistItem pli)
 {
     using (var scope = new ScopedDbContext <MusicDb>(serviceProvider))
     {
         var dr = GetDeviceRuntime(deviceKey);
         if (dr != null)
         {
             var item = pli.ToRuntime(scope.Db, dr);
             if (item != null)
             {
                 dr.Playlist.Items.Add(pli.ToRuntime(scope.Db, dr));
                 var dto = new PlaylistUpdateDTO
                 {
                     DeviceKey = deviceKey,
                     Items     = dr.Playlist.Items.Select(x => x.ToDTO())
                 };
                 await SendPlaylist(dto);
             }
         }
     }
 }