/// <summary> /// Checks whether this album has a specific artist. /// </summary> /// <param name="artist">Artist to be checked. Can be null.</param> /// <returns>True if the artist has this album or artist was null. Otherwise false.</returns> public virtual bool HasArtist(Artist artist) { if (artist == null) { return(false); } return(Artists.Any(a => artist.Equals(a.Artist))); }
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { if (viewModelState.Count == 0) { if (e.Parameter != null) { var parameter = JsonConvert.DeserializeObject <SearchNavigationParameter>(e.Parameter.ToString()); Query = parameter.Query; } Artists = new PaginatedCollection <LastArtist>(LoadMoreArtists); Artists.HasMoreItems = false; Artists.ContentState = ContentState.NoData; if (!String.IsNullOrWhiteSpace(Query)) { Search(); } else { HideCommandBar(); } } else { Query = (string)viewModelState[nameof(Query)]; _currentQuery = (string)viewModelState[nameof(_currentQuery)]; Artists = JsonConvert.DeserializeObject <PaginatedCollection <LastArtist> >( viewModelState[nameof(Artists)].ToString(), _lastImageSetConverter); Artists.LoadMoreItems = LoadMoreArtists; Artists.Page = (uint)viewModelState[nameof(Artists) + "PageOffset"]; Artists.ContentState = (ContentState)(int)viewModelState[nameof(Artists) + "State"]; if (Artists.ContentState == ContentState.NoData) { Artists.HasMoreItems = false; } if (!Artists.Any() && String.IsNullOrEmpty(Query)) { HideCommandBar(); } else { SetDefaultMode(); } } base.OnNavigatedTo(e, viewModelState); }
private async Task LoadFromDatabase() { await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Artists.Clear(); Tracks.Clear(); }); await MusicLibraryManagement.LoadFromSQL(); await DispatchHelper.InvokeAsync(() => { IsMusicLibraryEmpty = !Artists.Any(); OnPropertyChanged("IsMusicLibraryEmpty"); }); }
public Subject First() { if (People.Any()) { return(People.First()); } if (Artists.Any()) { return(Artists.First()); } if (Songs.Any()) { return(Songs.First()); } return(null); }
private async Task <IEnumerable <LastArtist> > LoadMoreArtists(uint page) { var response = await _lastfmClient.Artist.SearchAsync(_currentQuery, (int)(page + 1), 50); if (response.Success) { if (!Artists.Any()) { SetDefaultMode(); } return(response); } else { throw new Exception(); } }
public async Task GetMusicFromLibrary() { await LoadFromDatabase(); await App.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => IsMusicLibraryEmpty = false); if (!Artists.Any()) { await StartIndexing(); return; } await App.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { LoadingState = LoadingState.Loaded; IsLoaded = true; IsBusy = false; Locator.MainVM.InformationText = ""; }); MusicCollectionLoaded.SetResult(true); await PerformRoutineCheckIfNotBusy(); }
/// <summary> /// Checks whether this song has a specific artist. /// </summary> /// <param name="artistLink">Artist to be checked. Cannot be null.</param> /// <returns>True if the artist has this album. Otherwise false.</returns> public virtual bool HasArtistLink(ArtistForSong artistLink) { ParamIs.NotNull(() => artistLink); return(Artists.Any(a => a.ArtistLinkEquals(artistLink))); }
/// <summary> /// Checks whether this album has a specific artist. /// </summary> /// <param name="artistForAlbum">Artist to be checked. Cannot be null.</param> /// <returns>True if the artist has this album. Otherwise false.</returns> public virtual bool HasArtistForAlbum(ArtistForAlbum artistForAlbum) { ParamIs.NotNull(() => artistForAlbum); return(Artists.Any(a => a.ArtistLinkEquals(artistForAlbum))); }
public ViewModel() { DALService = new DALService(); loginCommand = new DelegateCommand(Login); registrationCommand = new DelegateCommand(Registration); loginRegistrationShowCommand = new DelegateCommand(ShowLoginRegistrationForm, () => !Accounts.Any(a => a.Login == currentAccount.Login && a.Password == currentAccount.Password)); exitCommand = new DelegateCommand(Exit, () => Accounts.Any(a => a.Login == currentAccount.Login && a.Password == currentAccount.Password)); addArtistCommand = new DelegateCommand(AddArtist, () => CurrentAccount.IsClient == false && Artist.Name != "" && !Artists.Any(a => a.Name == Artist.Name)); addGenreCommand = new DelegateCommand(AddGenre, () => Accounts.Contains(currentAccount) && CurrentAccount.IsClient == false); addPublisherCommand = new DelegateCommand(AddPublisher, () => Accounts.Contains(currentAccount) && CurrentAccount.IsClient == false); addRecordCommand = new DelegateCommand(AddRecord); editRecordCommand = new DelegateCommand(EditRecord, () => CurrentAccount.IsClient == false && SelectedRecord != null); removeRecordCommand = new DelegateCommand(RemoveRecord, () => SelectedRecord != null && CurrentAccount.IsClient == false); discardRecordCommand = new DelegateCommand(DiscardRecord, () => Accounts.Contains(currentAccount) && CurrentAccount.IsClient == false && SelectedRecord != null); sellRecordCommand = new DelegateCommand(Sell, () => CurrentAccount.IsClient == false && SelectedRecord != null && SelectedRecord.Name != "" && Date.Date == DateTime.Now.Date && Total > 0); setAsideCommand = new DelegateCommand(SetAside, () => Accounts.Contains(currentAccount) && CurrentAccount.IsClient == false && Client != null && Client.Email != "" && SelectedRecord != null && Date.Date >= DateTime.Now.Date); createDealCommand = new DelegateCommand(CreateDeal, () => CurrentAccount.IsClient == false); addRecordToDealCommand = new DelegateCommand(AddRecordToDeal, () => CurrentAccount.IsClient == false && Deal != null && SelectedRecord != null); searchCommand = new DelegateCommand(Search, () => Accounts.Any(a => a.Login == currentAccount.Login && a.Password == currentAccount.Password) && !String.IsNullOrWhiteSpace(SearchBy) && (!String.IsNullOrWhiteSpace(SearchLine) || SearchBy == "All")); showCommand = new DelegateCommand(Show, () => Accounts.Any(a => a.Login == currentAccount.Login && a.Password == currentAccount.Password) && !String.IsNullOrWhiteSpace(TopFor)); searchByList.Add("All"); searchByList.Add("Name"); searchByList.Add(nameof(Artist)); searchByList.Add(nameof(Genre)); topForTheList.Add("Day"); topForTheList.Add("Week"); topForTheList.Add("Month"); topForTheList.Add("Year"); TopFor = "Day"; selectedRecord = new Record() { DateOfPublishing = DateTime.Now }; artist = new Artist(); genre = new Genre(); publisher = new Publisher(); deal = new Deal() { StartDate = DateTime.Now, EndDate = DateTime.Now }; currentAccount = new Account() { Login = "", Password = "", IsClient = true }; currentClient = new Client() { Account = currentAccount, Name = "", Surname = "", Phone = "", Email = "", Discount = 0 }; client = new Client() { Account = new Account() { Login = "", Password = "" }, Name = "", Surname = "", Phone = "", Email = "", Discount = 0 }; FillAccounts(); FillClients(); PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(CurrentAccount)) { loginCommand.RaiseCanExecuteChanged(); registrationCommand.RaiseCanExecuteChanged(); loginRegistrationShowCommand.RaiseCanExecuteChanged(); exitCommand.RaiseCanExecuteChanged(); addArtistCommand.RaiseCanExecuteChanged(); addGenreCommand.RaiseCanExecuteChanged(); addPublisherCommand.RaiseCanExecuteChanged(); addRecordCommand.RaiseCanExecuteChanged(); addRecordToDealCommand.RaiseCanExecuteChanged(); editRecordCommand.RaiseCanExecuteChanged(); removeRecordCommand.RaiseCanExecuteChanged(); sellRecordCommand.RaiseCanExecuteChanged(); setAsideCommand.RaiseCanExecuteChanged(); showCommand.RaiseCanExecuteChanged(); searchCommand.RaiseCanExecuteChanged(); createDealCommand.RaiseCanExecuteChanged(); discardRecordCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(CurrentClient)) { loginCommand.RaiseCanExecuteChanged(); registrationCommand.RaiseCanExecuteChanged(); loginRegistrationShowCommand.RaiseCanExecuteChanged(); exitCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(Artist)) { addArtistCommand.RaiseCanExecuteChanged(); addRecordCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(Genre)) { addGenreCommand.RaiseCanExecuteChanged(); addRecordCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(Publisher)) { addRecordCommand.RaiseCanExecuteChanged(); addPublisherCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(SelectedRecord)) { addRecordCommand.RaiseCanExecuteChanged(); addRecordToDealCommand.RaiseCanExecuteChanged(); editRecordCommand.RaiseCanExecuteChanged(); discardRecordCommand.RaiseCanExecuteChanged(); removeRecordCommand.RaiseCanExecuteChanged(); sellRecordCommand.RaiseCanExecuteChanged(); setAsideCommand.RaiseCanExecuteChanged(); CalculateTotal(); } else if (args.PropertyName == nameof(Deal)) { createDealCommand.RaiseCanExecuteChanged(); addRecordToDealCommand.RaiseCanExecuteChanged(); CalculateTotal(); } else if (args.PropertyName == nameof(Date)) { sellRecordCommand.RaiseCanExecuteChanged(); setAsideCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(SearchBy)) { searchCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(SearchLine)) { searchCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(TopFor)) { showCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(Client)) { sellRecordCommand.RaiseCanExecuteChanged(); setAsideCommand.RaiseCanExecuteChanged(); CalculateTotal(); } else if (args.PropertyName == nameof(Total)) { sellRecordCommand.RaiseCanExecuteChanged(); } }; }