public NewsItemAuthors CreateNewsItemAuthor(int authorId, int newsItemId) { if (_authorRepository.GetAuthorById(authorId) != null) { if (_newsItemRepository.GetNewsItemById(newsItemId) != null) { if (!_authorRepository.CheckNewsItemAuthorRelation(authorId, newsItemId)) { return(_authorRepository.CreateNewsItemAuthor(authorId, newsItemId)); } throw new ResourceAlreadyExistsException(); } throw new ResourceNotFoundException($"News item with id {newsItemId} was not found."); } throw new ResourceNotFoundException($"Author with id {authorId} was not found."); }