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
            }));
        }
예제 #2
0
        public Book Map(IBook input, UrlHelper urlHelper)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }
            if (urlHelper == null)
            {
                throw new ArgumentNullException(nameof(urlHelper));
            }

            var bookUrl          = BookLinkCreator.CreateBookLink(input, urlHelper);
            var characterUrls    = input.Characters?.Select(c => CharacterLinkCreator.CreateCharacterLink(c, urlHelper));
            var povCharacterUrls = input.POVCharacters?.Select(c => CharacterLinkCreator.CreateCharacterLink(c, urlHelper));
            var mediaType        = _mediaTypeMapper.Map(input.MediaType, urlHelper);

            return(new Book(bookUrl, input.Name, input.ISBN, input.Authors, input.NumberOfPages, input.Publisher,
                            input.Country, mediaType, input.Released, characterUrls, povCharacterUrls));
        }
예제 #3
0
        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>()
            });
        }
예제 #4
0
        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>()
            });
        }