Example #1
0
        public void EditBook(Book book, int authorId)
        {
            BookValidation validation = new BookValidation(book);

            validation.BookGeneralValidation.ExecuteValidation();
            if (!validation.bookValidationExceptions.Any() &&
                !validation.BookGeneralValidation.generalValidationExceptions.Any())
            {
                _bookDao.EditBook(book, authorId);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                if (!validation.bookValidationExceptions.Any())
                {
                    foreach (var item in validation.bookValidationExceptions)
                    {
                        sb.Append(item + Environment.NewLine);
                    }
                }
                if (!validation.BookGeneralValidation.generalValidationExceptions.Any())
                {
                    foreach (var item in validation.BookGeneralValidation.generalValidationExceptions)
                    {
                        sb.Append(item + Environment.NewLine);
                    }
                }

                throw new BookValidationException(sb.ToString());
            }
        }