Пример #1
0
        private async void GetResults(string searchParameter)
        {
            if (!string.IsNullOrWhiteSpace(SearchParameter as string))
            {
                try
                {
                    SearchResult = await SearchResult.SearchByTitleAsync(searchParameter.ToString(), CurrentPage);

                    MoviesView = new ListCollectionView(SearchResult.Search.ToList());
                    Sorting(SortMethod);
                    await LocalStorageDAL.SaveLastSearch(searchParameter.ToString());

                    SetPageStaus(PageStatus, SearchResult.TotalResults);
                }
                catch (Exception xcp)
                {
                    if (SearchResult != null)
                    {
                        bool   response = SearchResult.Response;
                        string error    = SearchResult.Error;
                        messageService.ShowNotification(error);
                    }
                    else
                    {
                        messageService.ShowNotification(xcp.Message);
                    }
                }
            }
        }
Пример #2
0
        public async Task ImportExecute(object path)
        {
            //Sets the progress bar
            BadFolders = new List<string>();
            IEnumerable<string> folders = LocalStorageDAL.ReadMoviesFromFolder(path.ToString());
            await LocalStorageDAL.SaveLastPath(path.ToString());
            List<Movie> movieList = new List<Movie>();
            StringBuilder sb = new StringBuilder();
            foreach (string folder in folders)
            {
                sb = new StringBuilder();
                //Checks movie pattern
                Match match = Regex.Match(folder, @".+\s?\([0-9]+\)");
                if (match.Success)
                {
                    IEnumerable<char> charArray = folder.TakeWhile(c => c != '(');
                    foreach (char c in charArray)
                    {
                        sb.Append(c);
                    }
                    
                    Movie movie = await Movie.GetMovieByTitle(sb.ToString().Trim());

                    //Added to demonstrate loading as the loading time is mostly too short
                    await Task.Delay(750);
                    if (movie.ImdbID != null)
                    {
                        movieList.Add(movie);
                    }
                }
                else {
                    BadFolders.Add(folder);
                }
            }
            if (BadFolders.Count > 0)
            {
                sb = new StringBuilder();
                foreach (string folder in BadFolders)
                {
                    sb.AppendLine(folder);
                }
                messageService.ShowNotification("Following movies could not be parsed\n" + sb.ToString());
            }
            
            MovieCollection = new ListCollectionView(movieList);
            
           
            
        }
Пример #3
0
        //Adds new favorite
        private async void Favorite(object input)
        {
            if (input != null)
            {
                string        favoritedMovie = (input as Movie).ImdbID;
                List <string> idList         = await ReadFavorites();

                if (!idList.Contains(favoritedMovie))
                {
                    idList.Add(favoritedMovie);
                }
                else
                {
                    messageService.ShowNotification("Selected movie is already in favorites");
                }
                LocalStorageDAL.WriteFavorite(idList);
                GetMovies();
            }
        }