Ejemplo n.º 1
0
        public void CheckInOut()
        {
            Book book = BookDAO.Get(101);

            Assert.IsNotNull(book);
            Assert.AreEqual(2, book.InStock);

            BookDAO.CheckOut(101);
            book = BookDAO.Get(101);
            Assert.IsNotNull(book);
            Assert.AreEqual(1, book.InStock);

            BookDAO.CheckOut(101);
            book = BookDAO.Get(101);
            Assert.IsNotNull(book);
            Assert.AreEqual(0, book.InStock);

            BookDAO.CheckOut(101);
            book = BookDAO.Get(101);
            Assert.IsNotNull(book);
            Assert.AreEqual(0, book.InStock);


            BookDAO.CheckIn(101, 2);
            book = BookDAO.Get(101);
            Assert.IsNotNull(book);
            Assert.AreEqual(2, book.InStock);
        }
Ejemplo n.º 2
0
        public void AddShopItem(int id)
        {
            if (Session[DataKeys.ShopItems] == null)
            {
                Session[DataKeys.ShopItems] = new List <int>();
            }
            if (Session[DataKeys.ShopItemsCount] == null)
            {
                Session[DataKeys.ShopItemsCount] = 0;
            }

            List <int> shopItemCodes = (List <int>)Session[DataKeys.ShopItems];

            BookDAO.CheckOut(id);
            shopItemCodes.Add(id);

            int count = (int)Session[DataKeys.ShopItemsCount];

            Session[DataKeys.ShopItemsCount] = count + 1;
        }