public IHttpActionResult Get() { var booksUrl = BookLinkCreator.CreateBooksLink(Url); var charactersUrl = CharacterLinkCreator.CreateCharactersLink(Url); var housesUrl = HouseLinkCreator.CreateHousesLink(Url); return(Ok(new Endpoints { Books = booksUrl, Characters = charactersUrl, Houses = housesUrl })); }
public Character Map(ICharacter input, UrlHelper urlHelper) { if (input == null) { throw new ArgumentNullException(nameof(input)); } if (urlHelper == null) { throw new ArgumentNullException(nameof(urlHelper)); } var url = CharacterLinkCreator.CreateCharacterLink(input, urlHelper); var fatherUrl = CharacterLinkCreator.CreateCharacterLink(input.Father, urlHelper); var motherUrl = CharacterLinkCreator.CreateCharacterLink(input.Mother, urlHelper); var spouseUrl = CharacterLinkCreator.CreateCharacterLink(input.Spouse, urlHelper); var booksUrls = input.Books?.Select(b => BookLinkCreator.CreateBookLink(b, urlHelper)); var povBooksUrls = input.PovBooks?.Select(b => BookLinkCreator.CreateBookLink(b, urlHelper)); var allegiances = input.Allegiances?.Select(h => HouseLinkCreator.CreateHouseLink(h, urlHelper)); return(new Character(url) { Name = input.Name ?? string.Empty, Gender = _genderMapper.Map(input.Gender, urlHelper), Culture = input.Culture ?? string.Empty, Born = input.Born ?? string.Empty, Died = input.Died ?? string.Empty, Father = fatherUrl, Mother = motherUrl, Spouse = spouseUrl, Books = booksUrls ?? Enumerable.Empty <string>(), PovBooks = povBooksUrls ?? Enumerable.Empty <string>(), Aliases = input.Aliases ?? Enumerable.Empty <string>(), Titles = input.Titles ?? Enumerable.Empty <string>(), PlayedBy = input.PlayedBy ?? Enumerable.Empty <string>(), TvSeries = input.TvSeries ?? Enumerable.Empty <string>(), Allegiances = allegiances ?? Enumerable.Empty <string>() }); }
public House Map(IHouse input, UrlHelper urlHelper) { if (input == null) { throw new ArgumentNullException(nameof(input)); } if (urlHelper == null) { throw new ArgumentNullException(nameof(urlHelper)); } var url = HouseLinkCreator.CreateHouseLink(input, urlHelper); var currentLordUrl = CharacterLinkCreator.CreateCharacterLink(input.CurrentLord, urlHelper); var heirUrl = CharacterLinkCreator.CreateCharacterLink(input.Heir, urlHelper); var founderUrl = CharacterLinkCreator.CreateCharacterLink(input.Founder, urlHelper); var swornMembersUrls = input.SwornMembers?.Select(c => CharacterLinkCreator.CreateCharacterLink(c, urlHelper)); var overlordUrl = HouseLinkCreator.CreateHouseLink(input.Overlord, urlHelper); var cadetBranchesUrls = input.CadetBranches?.Select(h => HouseLinkCreator.CreateHouseLink(h, urlHelper)); return(new House(url, input.Name) { Region = input.Region ?? string.Empty, CoatOfArms = input.CoatOfArms ?? string.Empty, Words = input.Words ?? string.Empty, Founded = input.Founded ?? string.Empty, DiedOut = input.DiedOut ?? string.Empty, Titles = input.Titles ?? Enumerable.Empty <string>(), AncestralWeapons = input.AncestralWeapons ?? Enumerable.Empty <string>(), Seats = input.Seats ?? Enumerable.Empty <string>(), CurrentLord = currentLordUrl, Heir = heirUrl, Founder = founderUrl, SwornMembers = swornMembersUrls ?? Enumerable.Empty <string>(), Overlord = overlordUrl, CadetBranches = cadetBranchesUrls ?? Enumerable.Empty <string>() }); }