async void OnPlaylistSended(PlaylistDetailViewModel source, PlaylistViewModel playlistViewModel) { Playlist = playlistViewModel; Name = Playlist.Name; ObservableCollection <SongViewModel> tempList = new ObservableCollection <SongViewModel>(); foreach (Song songTemp in Playlist.Songs) { if (Playlist.CustomSongsOrder) { Song tempSong = await songRepository.GetSongWithChildren(songTemp.Id); tempSong.IsCheckBoxVisible = false; tempList.Add(new SongViewModel(tempSong)); } else { songTemp.IsCheckBoxVisible = false; tempList.Add(new SongViewModel(songTemp)); } } if (Playlist.CustomSongsOrder) { tempList = new ObservableCollection <SongViewModel>(tempList.OrderBy(s => s.Positions.Where(p => p.PlaylistId == Playlist.Id).FirstOrDefault().PositionOnPlaylist)); } foreach (SongViewModel song in tempList) { SongsList.Add(song); } PreparePresentation(); MessagingCenter.Unsubscribe <PlaylistDetailViewModel, PlaylistViewModel> (this, Events.SendPlaylistToPresentation); }
private void OnPlaylistUpdated(PlaylistDetailViewModel source, Playlist playlist) { var playlistInList = Playlists.Single(p => p.Id == playlist.Id); playlistInList.Id = playlist.Id; playlistInList.Name = playlist.Name; playlistInList.Songs = playlist.Songs; }
public PlaylistDetailView() { InitializeComponent(); var api = DependencyService.Get <IApi>(); BindingContext = new PlaylistDetailViewModel(api); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is string) { _vm = new PlaylistDetailViewModel((string)e.Parameter); DataContext = _vm; } base.OnNavigatedTo(e); }
private void OnDetailsViewDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) { if (args.NewValue == _prev) { return; } if (_prev != null) { _prev.Cleanup(); _prev = null; } if (args.NewValue is PlaylistDetailViewModel p) { _prev = p; } }
public async Task <IActionResult> Detail(int id) { string userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var playlist = await _applicationDbContext.PlayLists .Include(pl => pl.PlayListSongs) .ThenInclude(pls => pls.Song) .ThenInclude(song => song.Album) .ThenInclude(album => album.Band) .Include(playlist => playlist.PlaylistComments) .ThenInclude(comment => comment.User) .FirstOrDefaultAsync(pl => pl.Id == id); var vm = new PlaylistDetailViewModel { Id = playlist.Id, Name = playlist.Name, Songs = playlist.PlayListSongs .Select(pls => pls.Song) .Select(song => new PlaylistSong { Id = song.Id, SongTitle = song.Title, BandName = song.Album.Band.Name, AlbumTitle = song.Album.Title, Duration = song.Duration, ReleaseDate = song.Album.ReleaseDate, Url = song.SongLink }), PlaylistComments = playlist.PlaylistComments.Select(item => new PlaylistCommentViewModel { User = item.User.UserName, Content = item.Content }) }; return(View(vm)); }
private void OnPlaylistDeleted(PlaylistDetailViewModel source, Playlist playlist) { Playlists.Remove(Playlists.Where(p => p.Id == playlist.Id).Single()); OnPropertyChanged(nameof(Playlists)); }
public PlaylistDetailPage(PlaylistDetailViewModel viewModel) { InitializeComponent(); BindingContext = viewModel; }