Esempio n. 1
0
        public void AddAuthor(AuthorModel author)
        {
            _validator.ValidateAuthor(author);
            var authorFilter = new AuthorFilterModel {
                Name = author.Name
            };
            var dbAuthor = _authorRepository.Get(authorFilter).FirstOrDefault();

            if (dbAuthor is not null)
            {
                throw new CustomApiException(HttpStatusCode.UnprocessableEntity, Constants.AUTHORALREADYEXISTSERROR);
            }
            dbAuthor = _mapper.Map <AuthorEntity>(author);

            _authorRepository.Insert(dbAuthor);
        }