async Task ExecuteLoadFilmsCommand() { if (IsBusy) { return; } IsBusy = true; try { var filmsCount = await filmService.FilmsCount(); pagesCount = (int)Math.Ceiling((double)filmsCount / AppConstants.PAGE_SIZE); FilmTreshold = 4; Films.Clear(); var films = await filmService.GetAllFilms(); Films.AddRange(films); FilteredFilms.AddRange(films); } finally { IsBusy = false; } }
async Task FilmsTresholdReached() { if (IsBusy) { return; } IsBusy = true; try { pageNumber++; if (pageNumber > pagesCount) { FilmTreshold = -1; return; } var films = await filmService.GetAllFilms(pageNumber); FilteredFilms.AddRange(films); Films.AddRange(films); } finally { IsBusy = false; } }
public void AddRange(IEnumerable <Film> films) { if (films == null) { return; } var needFilms = films.Except(Films); foreach (var f in needFilms) { if (f.genre != null) { AllGenres.Add(f.genre.name); } if (f.FilmActor != null) { foreach (var fa in f.FilmActor) { if (fa.Actor != null) { AllActors.Add(fa.Actor.fullName); } } } } Films.AddRange(needFilms); }