コード例 #1
0
        public async Task <IEnumerable <Movie> > GetMoviesAsync(MovieQueryParameters movieQueryParameters)
        {
            if (movieQueryParameters == null)
            {
                throw new ArgumentNullException(nameof(movieQueryParameters));
            }

            string key = movieQueryParameters.GetKey();

            if (App.UseCache && cache.Contains(key) && cache.Get(key) is List <Movie> m)
            {
                return(m);
            }

            string ids = App.SearchService.GetMovieIds(movieQueryParameters);

            // todo - add CVectorBase
            // todo - remove trace headers
            // todo - change to dataservice app name
            // todo - should we cache this?
            // nothing found
            if (string.IsNullOrEmpty(ids))
            {
                return(new List <Movie>());
            }

            List <Movie> movies = (List <Movie>) await InternalCosmosDBSqlQuery <Movie>(ids).ConfigureAwait(false);

            cache.Add(new CacheItem(key, movies), cachePolicy);

            return(movies);
        }
コード例 #2
0
ファイル: dalMovies.cs プロジェクト: retaildevcrews/ngsa
        public async Task <IEnumerable <Movie> > GetMoviesAsync(MovieQueryParameters movieQueryParameters)
        {
            if (movieQueryParameters == null)
            {
                throw new ArgumentNullException(nameof(movieQueryParameters));
            }

            string key = movieQueryParameters.GetKey();

            if (App.Cache && cache.Contains(key) && cache.Get(key) is List <Movie> m)
            {
                return(m);
            }

            string sql = App.SearchService.GetMovieIds(movieQueryParameters);

            List <Movie> movies = new List <Movie>();

            // retrieve the items
            if (!string.IsNullOrWhiteSpace(sql))
            {
                movies = (List <Movie>) await InternalCosmosDBSqlQuery <Movie>(sql).ConfigureAwait(false);
            }

            // add to cache
            if (App.Cache)
            {
                cache.Add(new CacheItem(key, movies), cachePolicy);
            }

            return(movies);
        }