public async Task BeginSearch() { try { if (!string.IsNullOrEmpty(SearchQuery.SearchText) || !string.IsNullOrEmpty(SearchQuery.ActorName) || SearchQuery.Batch != null || !string.IsNullOrEmpty(SearchQuery.Mood)) { EventAgg.PublishOnUIThread(new StartLoadingMessage("Searching for movies...")); MovieList = await OnlineDB.Search(SearchQuery); if (MovieList != null || MovieList.Count != 0) { EventAgg.PublishOnUIThread(new MovieListMessage(MovieList, true, SearchQuery.SearchText)); } } } catch { StatusMessage.Enqueue("Unknow error occured while searchig for movies!"); } finally { EventAgg.PublishOnUIThread(new StopLoadingMessage()); } }
public async Task Load() { if (Movies.Count != 0) { return; } try { var movies = await OfflineDB.GetAllWatchListItems(CurrentUser); await base.PushToUI(movies); } catch { StatusMessage.Enqueue("Error while loading WatchList!"); } }
/// <summary> /// Remove the parameter Movie from the Movies collection and remove the Movie /// from the WatchList inside the DB /// </summary> public async void Handle(RemoveFromWatchListMessage message) { var movieCard = message.MovieCard; if (GetMovieCard(movieCard) == null) { return; } try { Movies.Remove(movieCard); await OfflineDB.RemoveFromWatchList(CurrentUser, movieCard.Movie); } catch { StatusMessage.Enqueue("Error while removing the movie from the WatchList!"); Movies.Remove(movieCard); } }
/// <summary> /// Add the parameter Movie to the Movies collection and add the Movie /// to the WatchList inside the DB /// </summary> public async void Handle(AddToWatchListMessage message) { var movieCard = message.MovieCard; if (GetMovieCard(movieCard) != null) { return; } try { Movies.Add(message.MovieCard); await OfflineDB.AddMovie(CurrentUser, movieCard.Movie); await OfflineDB.AddToWatchList(CurrentUser, message.MovieCard.Movie); } catch { StatusMessage.Enqueue("Error while adding the movie to the WatchList!"); Movies.Remove(message.MovieCard); } }