Exemple #1
0
        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}"));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
 public static Book NewBookFrom(
     BookId id,
     BookName bookName,
     YearOfPrint yearOfPrint) =>
 (Book) new Book().ApplyChange(new BookAdded(id, bookName, yearOfPrint));
Exemple #4
0
 public static BookId ToBookId(this string bookIdString) =>
 BookId.BookIdFrom(bookIdString);