public IHttpActionResult AddAuthor(AuthorDto authorDto)
        {
            var Name = GetEmailFromRequestHeader();

            if (Name == "*****@*****.**")
            {
                return(BadRequest("This user cannot make changes to the database!"));
            }

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

            if (authorDto == null)
            {
                return(BadRequest());
            }

            Author author = ConversionUtility.AuthorDtoToAuthor(authorDto);

            var authorInDb = _context.Authors.Add(author);

            _context.SaveChanges();

            var authorToReturn = ConversionUtility.AuthorToAuthorDto(authorInDb);

            return(Ok(authorToReturn));
        }
        public IHttpActionResult UpdateAuthor(int id, AuthorDto authorDto)
        {
            var Name = GetEmailFromRequestHeader();

            if (Name == "*****@*****.**")
            {
                return(BadRequest("This user cannot make changes to the database!"));
            }

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

            if (id != authorDto.Id)
            {
                return(BadRequest());
            }

            Author author = ConversionUtility.AuthorDtoToAuthor(authorDto);

            _context.Entry(author).State = EntityState.Modified;

            _context.SaveChanges();

            var authorToReturn = ConversionUtility.AuthorToAuthorDto(author);

            return(Ok(authorToReturn));
        }
        public IHttpActionResult GetAuthor(int id)
        {
            var author = _context.Authors.SingleOrDefault(a => a.Id == id);

            if (author == null)
            {
                return(NotFound());
            }

            AuthorDto authorDto = ConversionUtility.AuthorToAuthorDto(author);

            return(Ok(authorDto));
        }