public Result <User> FinishBorrowOf(BookId bookId) { if (IsBorrowingABook && _maybeBorrowedBook.Value == bookId) { ApplyChange(new UserFinishedBookBorrow(Id, _fullName, bookId)); return(Ok(this)); } return(Fail <User>($"User {Id} is not borrowing a book {bookId}")); }
public Result <User> BorrowBook(BookId bookToLendId) { if (IsBorrowingABook) { return(Fail <User>($"User {Id} has already borrowed book '{_maybeBorrowedBook.Value}'.")); } ApplyChange(new UserBorrowedBook(Id, _fullName, bookToLendId)); return(Ok(this)); }
public static Book NewBookFrom( BookId id, BookName bookName, YearOfPrint yearOfPrint) => (Book) new Book().ApplyChange(new BookAdded(id, bookName, yearOfPrint));
public static BookId ToBookId(this string bookIdString) => BookId.BookIdFrom(bookIdString);