private async Task QueueEntity <T>(Device device, T entity) { var playlist = device.Playlist; //var pli = CreateNewPlaylistItem(entity); PlaylistItem pli = null; switch (entity) { case MusicFile mf: pli = CreateNewPlaylistItem(mf); break; case Track t: pli = CreateNewPlaylistItem(t); break; case Work w: pli = CreateNewPlaylistItem(w); break; case Performance p: pli = CreateNewPlaylistItem(p); break; default: throw new Exception($"Entity type {entity.GetType().Name} is not playable"); } playlist.AddPlaylistItem(pli); await musicDb.SaveChangesAsync(); //now we need to send out a playlist update .. await musicDb.FillPlaylistItemForRuntime(pli); await playManager.AddPlaylistItem(device.KeyName, pli); //return SuccessResult(); }