예제 #1
0
        public Book(Guid id, string title, string isbn, IBookUniquenessChecker uniquenessChecker)
            : this(id)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ApplicationException("Title is required");
            }
            if (string.IsNullOrWhiteSpace(isbn))
            {
                throw new ApplicationException("ISBN is required");
            }
            if (uniquenessChecker.IsTitleExist(title))
            {
                throw new ApplicationException("Title is already exist");
            }
            if (uniquenessChecker.IsISBNExist(isbn))
            {
                throw new ApplicationException("ISBN is already exist");
            }

            title = title.Trim();
            isbn  = isbn.Trim();
            RaiseEvent(new BookRegistered {
                Id = id, Title = title, ISBN = isbn
            });
        }
예제 #2
0
        public void Correct(string title, IBookUniquenessChecker uniquenessChecker)
        {
            if (string.IsNullOrWhiteSpace(title)) throw new ApplicationException("Title is required");
            if (deleted) throw new ApplicationException("This book has already deleted");

            title = title.Trim();
            if (this.title != title)
            {
                if (uniquenessChecker.IsTitleExist(title)) throw new ApplicationException("Title is already exist");
                RaiseEvent(new BookCorrected { Id = Id, Title = title });
            }
        }
예제 #3
0
        public Book(Guid id, string title, string isbn, IBookUniquenessChecker uniquenessChecker)
            : this(id)
        {
            if (string.IsNullOrWhiteSpace(title)) throw new ApplicationException("Title is required");
            if (string.IsNullOrWhiteSpace(isbn)) throw new ApplicationException("ISBN is required");
            if (uniquenessChecker.IsTitleExist(title)) throw new ApplicationException("Title is already exist");
            if (uniquenessChecker.IsISBNExist(isbn)) throw new ApplicationException("ISBN is already exist");

            title = title.Trim();
            isbn = isbn.Trim();
            RaiseEvent(new BookRegistered { Id = id, Title = title, ISBN = isbn });
        }
예제 #4
0
        public void Correct(string title, IBookUniquenessChecker uniquenessChecker)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ApplicationException("Title is required");
            }
            if (deleted)
            {
                throw new ApplicationException("This book has already deleted");
            }

            title = title.Trim();
            if (this.title != title)
            {
                if (uniquenessChecker.IsTitleExist(title))
                {
                    throw new ApplicationException("Title is already exist");
                }
                RaiseEvent(new BookCorrected {
                    Id = Id, Title = title
                });
            }
        }