示例#1
0
        /// <summary>
        /// To remove book from the cart
        /// </summary>
        /// <param name="bookCartItem">book cart item</param>
        public void RemoveBook(BookCartItem bookCartItem)
        {
            if (bookCartItem != null && bookCartItem.Book != null)
            {
                var existingBookCartItem = BookCartItems.FirstOrDefault(b => b.Book != null && b.Book.ID == bookCartItem.Book.ID);
                if (existingBookCartItem != null)
                {
                    BookCartItems.Remove(existingBookCartItem);
                }

                UpdateTotalPrice();
            }
        }
示例#2
0
        /// <summary>
        /// To Update the book cart item quantity
        /// </summary>
        /// <param name="bookCartItem">book cart item</param>
        /// <param name="quantity">number of quantity</param>
        public void UpdateQuantity(BookCartItem bookCartItem, int quantity)
        {
            if (bookCartItem != null && bookCartItem.Book != null)
            {
                var existingBookCartItem = BookCartItems.FirstOrDefault(b => b.Book != null && b.Book.ID == bookCartItem.Book.ID);
                if (existingBookCartItem != null)
                {
                    existingBookCartItem.Quantity = quantity;
                }

                UpdateTotalPrice();
            }
        }
示例#3
0
        /// <summary>
        /// To add book to the cart
        /// </summary>
        /// <param name="bookCartItem">book cart item</param>
        public void AddBook(BookCartItem bookCartItem)
        {
            if (bookCartItem != null && bookCartItem.Book != null)
            {
                var existingBookCartItem = BookCartItems.FirstOrDefault(b => b.Book != null && b.Book.ID == bookCartItem.Book.ID);
                if (existingBookCartItem == null)
                {
                    BookCartItems.Add(bookCartItem);
                }
                else
                {
                    existingBookCartItem.Quantity += bookCartItem.Quantity;
                }

                UpdateTotalPrice();
            }
        }