Exemplo n.º 1
0
 public Task <int> GetSearchFullCount(string query)
 {
     return(FullTextMovieSource.GetResultCount(_appContext, query));
 }
Exemplo n.º 2
0
        public IItemsSource GetMovieSource(ItemsSourceReference itemsSourceReference = null)
        {
            IItemsSource itemsSource = null;

            if (itemsSourceReference != null)
            {
                ItemsSourceReference current = null;
                if (_sourcesCache.TryGetValue(itemsSourceReference, out itemsSource))
                {
                    current = itemsSource.GetStateRepresentation();
                }
                if (!itemsSourceReference.Equals(current))
                {
                    switch (itemsSourceReference.Type)
                    {
                    case ItemsSourceType.Movie:
                        switch (itemsSourceReference.Filter)
                        {
                        case ItemsSourceFilter.All:
                            itemsSource = new AllMovieSource(_appContext);
                            break;

                        case ItemsSourceFilter.Cast:
                            itemsSource = new CastMovieSource(_appContext, itemsSourceReference.Param);
                            break;

                        case ItemsSourceFilter.Id:
                            itemsSource = new IdMovieSource(_appContext, int.Parse(itemsSourceReference.Param));
                            break;

                        case ItemsSourceFilter.Title:
                            itemsSource = new TitleMovieSource(_appContext, itemsSourceReference.Param);
                            break;

                        case ItemsSourceFilter.FullText:
                            itemsSource = new FullTextMovieSource(_appContext, itemsSourceReference.Param);
                            break;
                        }
                        break;

                    case ItemsSourceType.Episode:
                        switch (itemsSourceReference.Filter)
                        {
                        case ItemsSourceFilter.Cast:
                            itemsSource = new CastEpisodesSource(_appContext, itemsSourceReference.Param);
                            break;
                        }
                        break;

                    case ItemsSourceType.TVShow:
                        switch (itemsSourceReference.Filter)
                        {
                        case ItemsSourceFilter.Title:
                            itemsSource = new TitleTVShowSource(_appContext, itemsSourceReference.Param);
                            break;

                        case ItemsSourceFilter.Cast:
                            itemsSource = new CastTTVShowSource(_appContext, itemsSourceReference.Param);
                            break;

                        case ItemsSourceFilter.All:
                            itemsSource = new TvShowSource(_appContext);
                            break;

                        case ItemsSourceFilter.Id:
                            itemsSource = new TvShowIdSource(_appContext, int.Parse(itemsSourceReference.Param));
                            break;
                        }
                        break;

                    case ItemsSourceType.WatchList:
                        switch (itemsSourceReference.Filter)
                        {
                        case ItemsSourceFilter.All:
                            itemsSource = new WatchlistMovieSource(_appContext);
                            break;
                        }
                        break;

                    case ItemsSourceType.Season:
                        switch (itemsSourceReference.Filter)
                        {
                        case ItemsSourceFilter.All:
                            itemsSource = new WatchlistMovieSource(_appContext);
                            break;
                        }
                        break;

                    case ItemsSourceType.Extern:
                        switch (itemsSourceReference.Filter)
                        {
                        case ItemsSourceFilter.Cast:
                            itemsSource = new CastTmdbResult(itemsSourceReference.Param);
                            break;

                        case ItemsSourceFilter.Title:
                            itemsSource = new TmdbResult(itemsSourceReference.Param);
                            break;
                        }
                        break;
                    }
                }
                _sourcesCache[itemsSourceReference] = itemsSource;
                current = itemsSource.GetStateRepresentation();
                if ((itemsSource.Selected == null ||
                     itemsSourceReference.Selection != current.Selection) &&
                    itemsSourceReference.Selection >= 0)
                {
                    itemsSource.RestoreSelection(itemsSourceReference.Selection);
                }
            }
            if (itemsSource == null)
            {
                itemsSource = new AllMovieSource(_appContext);
            }
            return(itemsSource);
        }