/// <summary> /// Does the search movie. /// </summary> /// <returns>The search movie.</returns> /// <param name="letter">Letter.</param> async Task DoSearchMovie(string letter) { if (string.IsNullOrEmpty(letter)) { GetLocalMovieList(); return; } var sorted = resultsService.GetAll().Where(x => x.OriginalTitle.ToLowerInvariant().Contains(letter.ToLowerInvariant())) .ToList(); try { if (sorted == null || !sorted.Any()) { sorted = await resultsService .GetAllRemoteData(APIOperations.SearchMovieURLAddres, ConfigureParameters(APIOperations.SearchMovieURLAddres, 1, letter)); sorted = AddImageLinkAndRemoveRepeated(sorted); } Movies = new ObservableCollection <Results>(sorted); } catch (ConnectionException) { uiFunctionsService.HideLoading(); uiFunctionsService.ShowToast(Constants.OfflineMessage, ToastType.Info, 8000); } catch (FetchRemoteDataException) { uiFunctionsService.ShowToast(Constants.GetOnlineDataErrorMessage, ToastType.Error, 8000); GetLocalMovieList(); } catch { mobileCenterCrashesService.AskBeforeSendCrashReport(); uiFunctionsService.ShowToast(Constants.GeneralErrorMessage, ToastType.Warning, 8000); GetLocalMovieList(); } finally { analyticsFunctionsService.TrackEvent(AnalitycsEventsName.SearchMovie, new Dictionary <string, string> { { letter, sorted.Count.ToString() } }); } }
/// <summary> /// Gets the movie list. /// </summary> async void GetMovieList() { try { uiFunctionsService.ShowLoading(Constants.MessageLoadingMoviesForTheFirstTime); var img = await imagesService.GetRemoteData(APIOperations.Configuration, ConfigureParameters(APIOperations.Configuration)); if (img != null) { settingsService.Set("IMGURL", img.BaseUrl); } await genresService.GetAllRemoteData(APIOperations.Genres, ConfigureParameters(APIOperations.Genres)); var ret = await resultsService.GetAllRemoteData(APIOperations.GetMovieListURLAddress, ConfigureParameters(APIOperations.GetMovieListURLAddress)); ret = AddImageLinkAndRemoveRepeated(ret); Movies = new ObservableCollection <Results>(ret); uiFunctionsService.HideLoading(); } catch (FetchRemoteDataException) { uiFunctionsService.HideLoading(); uiFunctionsService.ShowToast(Constants.GetOnlineDataErrorMessage, ToastType.Error, 8000); } catch (ConnectionException) { uiFunctionsService.HideLoading(); uiFunctionsService.ShowToast(Constants.OfflineMessage, ToastType.Info, 8000); GetLocalMovieList(); } catch { uiFunctionsService.HideLoading(); mobileCenterCrashesService.AskBeforeSendCrashReport(); uiFunctionsService.ShowToast(Constants.GeneralErrorMessage, ToastType.Error, 8000); } }