예제 #1
0
        public int AddAuthor(Author author)
        {
            AuthorValidation validation = new AuthorValidation(author);

            validation.FirstNameIsValid = validation.AuthorFirstNameValidation();
            validation.LastNameIsValid  = validation.AuthorLastNameValidation();
            if (!validation.exceptionList.Any())
            {
                return(_authorDao.AddAuthor(author));
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                foreach (var item in validation.exceptionList)
                {
                    sb.Append(item + Environment.NewLine);
                }
                throw new AuthorValidationException(sb.ToString());
            }
        }