public void Execute(object parameter) { var moviesArray = (object[])parameter; if (!(moviesArray[0] is Movie selectedPossibleMatch)) { return; } if (!(moviesArray[1] is Movie currentSelectedMovie)) { return; } selectedPossibleMatch.FileLocation = _fileController.RenameFile(currentSelectedMovie.FileLocation, selectedPossibleMatch.Title); _commonData.CommonDataMovies.Remove(currentSelectedMovie); selectedPossibleMatch.BackdropColor = selectedPossibleMatch.GetImageMajorityColor(); _commonData.UpdateValue(cd => cd.CommonDataSelectedMovie, selectedPossibleMatch); var movies = _commonData.CommonDataMovies; movies.Add(selectedPossibleMatch); _commonData.UpdateValue(cd => cd.CommonDataMovies, movies); _fileController.StoreMovieData(movies); }
public void Execute(object parameter) { var exisitingMovieLibrary = _fileController.GetMovieDataFromLocalLibraryFile(); var movies = new ConcurrentBag <Movie>(_fileController.FindLocalMovieFiles()); var concurrentMovieList = new ConcurrentBag <Movie>(); Parallel.ForEach(movies, _parallelOptions, m => { var existingMatch = exisitingMovieLibrary.FirstOrDefault(x => x.FileLocation == m.FileLocation && !string.IsNullOrEmpty(x.TagLine) && !string.IsNullOrEmpty(x.Title)); if (existingMatch != null) { concurrentMovieList.Add(existingMatch); } else { var mov = Task.Run(() => _apiController.EnrichMovieMatchedByTitle(m)).Result; concurrentMovieList.Add(mov); //// Yeh......ought to look into issues around API latency to get around this Thread.Sleep(500); } }); _commonData.UpdateValue(cd => cd.CommonDataMovies, concurrentMovieList.OrderBy(x => x.Title).ToList()); _fileController.StoreMovieData(concurrentMovieList.ToList()); }
public void Execute(object parameter) { if (!(parameter is string searchTerm) || searchTerm.Length < 1) { return; } _commonData.UpdateValue(cd => cd.CommonDataPossibleMatches, Task.Run(() => _apiController.GetPossibleMatchesFromApi(searchTerm)).Result); }
public DashboardViewModel() { _commonData = AutofacInstaller.Container.Resolve <ICommonDataViewModel>(); _scanForLocalMovieFilesCommand = AutofacInstaller.Container.Resolve <IScanForLocalMovieFilesCommand>(); _playMovieCommand = AutofacInstaller.Container.Resolve <IPlayMovieCommand>(); _slideGridCommand = AutofacInstaller.Container.Resolve <ISlideGridCommand>(); this._searchForMovieByTitleCommand = AutofacInstaller.Container.Resolve <ISearchForMovieByTitleCommand>(); _selectMatchedMovieCommand = AutofacInstaller.Container.Resolve <ISelectMatchedMovieCommand>(); _commonData.PropertyChanged += CommonDataPropertyChanged; var fileController = AutofacInstaller.Container.Resolve <IFileController>(); _commonData.UpdateValue(cd => cd.CommonDataMovies, fileController.GetMovieDataFromLocalLibraryFile()); }