Esempio n. 1
0
        public async Task CreateOrUpdateTvShowAsync(int tvShowId, CancellationToken cancellationToken)
        {
            var tvShowExternalModel = await _tvMazeClient.GetTvShowInfoAsync(tvShowId, cancellationToken);

            if (tvShowExternalModel == null)
            {
                throw new EntityNotFoundException($"Tv show with id: {tvShowId} was not found at TvMaze api side.");
            }

            var tvShow = _mapper.Map <TvShow>(tvShowExternalModel);

            await _presentationDal.InsertOrUpdateItemAsync(tvShow, cancellationToken);
        }
        public async Task CreateOrUpdateTvShowAsync(IntegrationItem sagaItem, CancellationToken cancellationToken)
        {
            if (sagaItem == null)
            {
                throw new ArgumentNullException(nameof(sagaItem));
            }

            var tvShowExternalModel = await _tvMazeClient.GetTvShowInfoAsync(sagaItem.Id, cancellationToken);

            if (tvShowExternalModel == null)
            {
                throw new EntityNotFoundException($"Tv show with id: {sagaItem.Id} was not found at TvMaze api side.");
            }

            var tvShow = _mapper.Map <TvShow>(tvShowExternalModel);

            await _presentationDal.InsertOrUpdateItemAsync(tvShow, cancellationToken);
        }