Ejemplo n.º 1
0
        public IActionResult Books(string Id)
        {
            var orderItems = _context.OrderItems.Include(c => c.Books.Categories).
                             Include(x => x.Orders.ApplicationUser).Where(o => o.Orders.ApplicationUserId == Id).ToList();
            PurchasedBooks model = new PurchasedBooks();

            model.items = orderItems;


            return(View(model));
        }
Ejemplo n.º 2
0
        public void PurchaseBook(Book book)
        {
            if (CanPurchaseBook(book).Any())
            {
                throw new InvalidOperationException();
            }

            book.AddBookReader(this);
            var purchasedBook = new PurchasedBook(book, this);

            PurchasedBooks.Add(purchasedBook);
        }
Ejemplo n.º 3
0
        public IReadOnlyList <ErrorCode> CanPurchaseBook(Book book)
        {
            var errors = (List <ErrorCode>)book.CanAddBookReader(this);

            if (HasPurchasedBook(book))
            {
                errors.Add(ErrorCode.YOU_HAVE_THIS_BOOK);
            }
            if (PurchasedBooks.Count() >= MAX_BOOK_COUNT)
            {
                errors.Add(ErrorCode.BOOK_LIMIT_ERROR);
            }

            return(errors);
        }
Ejemplo n.º 4
0
 public bool HasPurchasedBook(Book book)
 {
     return(PurchasedBooks.Any(x => x.Book == book));
 }