public async Task <LookupSeriesByTermResponse> Handle(LookupSeriesByTermRequest request, CancellationToken cancellationToken)
        {
            var model = new LookupSeriesByTermResponse();

            model.Series = await _sonarrClient.GetResponseCollection <Series>($"api/series/lookup?term={request.Term}");

            return(model);
        }
        public async Task <GetAllSeriesResponse> Handle(GetAllSeriesRequest request, CancellationToken cancellationToken)
        {
            var model = new GetAllSeriesResponse();

            model.Series = await _sonarrClient.GetResponseCollection <Series>($"api/series");

            return(model);
        }
Beispiel #3
0
        public async Task <LookupSeriesByIdResponse> Handle(LookupSeriesByIdRequest request, CancellationToken cancellationToken)
        {
            var model  = new LookupSeriesByIdResponse();
            var result = await _sonarrClient.GetResponseCollection <Series>($"api/series/lookup?term=tvdb:{request.Id}");

            if (result.Any())
            {
                model.Series = result.FirstOrDefault();
            }
            else
            {
                model.Series = null;
            }

            return(model);
        }
        public async Task <GetSingleSeriesByTvdbIdResponse> Handle(GetSingleSeriesByTvdbIdRequest request, CancellationToken cancellationToken)
        {
            if (int.TryParse(request.TvdbId, out int tvdbId))
            {
                var model  = new GetSingleSeriesByTvdbIdResponse();
                var result = await _sonarrClient.GetResponseCollection <Series>($"api/series");

                if (result.Any())
                {
                    model.Series = result.FirstOrDefault(x => x.TvdbId == tvdbId);
                }
                else
                {
                    model.Series = null;
                }

                return(model);
            }

            throw new Exception("Unable to parse tvdbId");
        }