//I actually don't know how to write a //constructor for this. Do we pass in ids? //eShopOnWeb passes in ids, so we will, too //Not sure that passing the enum in is the right call public UserBook(int userId, int bookId, UserBookStatus status, int?priority, float?rating) { UserId = userId; BookId = bookId; Status = status; Priority = priority; Rating = rating; DateAdded = DateTime.Now; }
//I'm convinced something like this has to exist SOMEWHERE. This is just a rough first go at it public void CreateUserBook(Book book, IEnumerable <Author> authors, int roleId, int userId, UserBookStatus status, int?priority, int?rating) { _unitOfWork.BookRepository.Add(book); foreach (var author in authors) { _unitOfWork.AuthorRepository.Add(author); _unitOfWork.BookAuthorRepository.Add(new BookAuthor(roleId, book.BookId, author.AuthorId)); } _unitOfWork.UserBookRepository.Add(new UserBook(userId, book.BookId, status, priority, rating)); }