Esempio n. 1
0
        public IActionResult GetCountryOfAnAuthor(int AuthorId)
        {
            //TO Do validate author exists.
            if (!_countryRepository.AuthorExists(AuthorId))
            {
                return(NotFound());
            }

            var Country = _countryRepository.GetCountryOfAuthor(AuthorId);

            if (!ModelState.IsValid)
            {
                BadRequest(ModelState);
            }
            var CountryDto = new CountryDto()
            {
                Id = Country.Id, Name = Country.Name
            };

            return(Ok(CountryDto));
        }
        public IActionResult GetCountryOfAnAuthor(int authorId)
        {
            if (!_countryRepository.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var country = _countryRepository.GetCountryOfAnAuthor(authorId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var countryDto = new CountryDto()
            {
                Id   = country.Id,
                Name = country.Name
            };

            return(Ok(countryDto));
        }