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