Ejemplo n.º 1
0
        public async Task <ShowDto> GetShowDataById(int showId,
                                                    CancellationToken cancellationToken = default(CancellationToken))
        {
            var jshow = await _jsonApiDataReader.GetJsonData <dynamic>(
                new Uri($"/shows/{showId}?embed=cast", UriKind.Relative), cancellationToken);

            var show = new ShowDto
            {
                Id   = jshow.id,
                Name = jshow.name
            };
            var embedded = jshow._embedded;

            if (embedded is null)
            {
                _logger.LogError($"No embedded data returned for show {showId}.");
            }
            else
            {
                var jcast = embedded.cast;
                if (jcast is null)
                {
                    _logger.LogError($"No cast data found embedded for show {showId}.");
                }
                else
                {
                    show.Cast.AddRange(GetCasts(jcast));
                }
            }

            return(show);
        }
Ejemplo n.º 2
0
        public async Task <ShowDto> GetShowDataById(int showId,
                                                    CancellationToken cancellationToken = default(CancellationToken))
        {
            var jshow = await _jsonApiDataReader.GetJsonData <dynamic>(
                new Uri($"/shows/{showId}?embed=cast", UriKind.Relative), cancellationToken);

            var show = new ShowDto
            {
                Id   = jshow.id,
                Name = jshow.name
            };
            var embedded = jshow._embedded;

            if (embedded is null)
            {
                _logger.LogError($"No embedded data returned for show {showId}.");
            }
            else
            {
                var jcast = embedded.cast;
                if (jcast is null)
                {
                    _logger.LogError($"No cast data found embedded for show {showId}.");
                }
                else
                {
                    foreach (var container in jcast)
                    {
                        var person    = container.person;
                        var personDto = new PersonDto
                        {
                            Id        = person.id,
                            Name      = person.name,
                            Birthdate = person.birthday,
                        };

                        show.Cast.Add(personDto);
                    }
                }
            }

            return(show);
        }