public void RemoveFromPending(Customer c, PurchasedItem pi, Transaction t)
 {
     foreach (Customer cust in customers)
     {
         if (cust == c)
         {
             c.RemoveBookFromHistory(t, pi);
         }
     }
 }
Esempio n. 2
0
        public void AddToCart(Book b)
        {
            if (b.Stock <= 0)
            {
                throw new BookShopException("This book is out of stock.");
            }
            foreach (PurchasedItem pi in currentCart.Cart)
            {
                if (pi.Book.ISBN == b.ISBN)
                {
                    pi.Quantity++;
                    currentCart.Price += b.Price;
                    b.Stock--;
                    return;
                }
            }
            PurchasedItem p = new PurchasedItem(b, 1);

            currentCart.Cart.Add(p);
            currentCart.Price += p.Book.Price;
            b.Stock--;
        }
Esempio n. 3
0
 public void RemoveBookFromHistory(Transaction t, PurchasedItem pi)
 {
     foreach (Transaction trans in transactionHistory)
     {
         if (trans == t)
         {
             foreach (PurchasedItem p in t.Cart)
             {
                 if (pi == p)
                 {
                     pi.Quantity--;
                     t.Price -= pi.Book.Price;
                     pi.Book.Stock++;
                     if (pi.Quantity <= 0)
                     {
                         t.Cart.Remove(pi);
                     }
                     break;
                 }
             }
         }
     }
 }