Ejemplo n.º 1
0
        public Task AddToResearchQueue(DTO.MediaType type, string imdb)
        {
            if (string.IsNullOrWhiteSpace(imdb))
            {
                throw new BadRequestException("imdb is empty", imdb);
            }

            return(_movieDatabaseProxy.AddToResearchQueue(type.ToString(), imdb));
        }
Ejemplo n.º 2
0
        public async Task <DTO.Media> GetMovieOrTvSeries(DTO.MediaType type, string name)
        {
            if (name == null)
            {
                throw new BadRequestException("name is empty", name);
            }
            name = name.Trim();
            if (name.Length < 2)
            {
                throw new BadRequestException("name has too few characters", name);
            }

            string cacheKey = $"{type}_{name.ToLower().Replace(" ","")}";

            var result = await _cacheWrapper.GetOrSetFromCache(cacheKey, async() =>
            {
                return(await _movieDatabaseProxy.GetMovieOrTvSeries(type.ToString(), name));
            });

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <DTO.Media> GetMovieOrTvSeries(DTO.MediaType type, string name)
        {
            // could have used usual validators, but because this is simple, and in the spirit of no "magic code", I preferred to do manually
            if (name == null)
            {
                throw new BadRequestException("name is empty");
            }
            name = name.Trim();
            if (name.Length < 2)
            {
                throw new BadRequestException("name has too few characters");
            }

            string cacheKey = $"{type}_{name.ToLower().Replace(" ", "")}";

            var result = await _memoryCache.GetOrSetFromCache(cacheKey, async() =>
            {
                return(await _movieDatabaseProxy.GetMovieOrTvSeries(type.ToString(), name));
            });

            return(result);
        }