public IActionResult GetPerson(string id) { var person = _dataService.GetPerson(id); var profession = _dataService.GetProfessionByPersonId2(id); var personKnownTitle = _dataService.GetPersonKnownTitles(id); IList <ProfessionDTO> professionDtos = profession.Select(x => new ProfessionDTO { ProfessionName = x.Profession.ProfessionName, Id = x.Profession.Id, Url = "http://localhost:5001/api/" + x.Profession.ProfessionName }).ToList(); IList <PersonDTO> personDtos = person.Select(x => new PersonDTO { Id = x.Id, Name = x.Name, BirthYear = x.BirthYear, DeathYear = x.DeathYear }).ToList(); IList <PersonKnownTitleDTO> personKnownTitleDtos = personKnownTitle.Select(x => new PersonKnownTitleDTO { Id = x.Id, TitleId = x.TitleId, TitleName = _titleDataService.GetTitle(x.TitleId).OriginalTitle.ToString(), Url = "http://localhost:5001/api/title/" + x.TitleId }).ToList(); return(Ok(new { personDtos, professionDtos, personKnownTitleDtos })); }
public IActionResult GetTitle(string id) { var title = _dataService.GetTitle(id); var titleGenre = _dataService.GetTitleGenres(id); var titleAkas = _dataService.GetTitleAkas(id); var titleEpisode = _dataService.GetMoreTitleEpisode(id); var titleEpisodeParentName = _dataService.GetTitleEpisodeParentName(id); var titlePerson = _dataService.GetTitlePersons(id); var titleType = _dataService.GetTitleType(id); if (title == null) { return(NotFound()); } var titleDto = _mapper.Map <TitleDto>(title); titleDto.Url = Url.Link(nameof(GetTitle), new { id }); if (titleGenre == null) { return(NotFound()); } titleDto.Type = titleType.Type.TypeName; titleDto.TypeUrl = "http://localhost:5001/api/type/" + titleType.Type.Id; IList <TitleGenreDTO> TitleGenres = titleGenre.Select(x => new TitleGenreDTO { Name = x.Genre.Name, Url = "http://localhost:5001/api/genre/" + x.GenreId }).ToList(); IList <TitleAkasDTO> TitleAkases = titleAkas.Select(x => new TitleAkasDTO { Name = x.AkasName, Region = x.Region, Url = "http://localhost:5001/api/title/akas/" + x.Id }).ToList(); IList <TitlePersonDTO> TitlePersons = titlePerson.Select(x => new TitlePersonDTO { Id = x.Id, Name = x.Name, Url = "http://localhost:5001/api/name/" + x.Id }).ToList(); if (titleEpisode == null) { return(Ok(new { titleDto, TitleGenres, TitleAkases, TitlePersons })); } IList <TitleEpisodeDto> TitleEpisodes = titleEpisode.Select(x => new TitleEpisodeDto { Id = x.TitleId, TitleName = x.Title.PrimaryTitle, Url = "http://localhost:5001/api/title/" + x.TitleId }).ToList(); foreach (var episode in TitleEpisodes) { episode.ParentTitleName = titleEpisodeParentName; } return(Ok(new { titleDto, TitleGenres, TitleAkases, TitleEpisodes, TitlePersons })); }