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 }); }
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 }); } }
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 }); }
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 }); } }