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); }
public void DeleteShopItem(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]; int boughtItems = shopItemCodes.FindAll(bCode => bCode == id).Count; BookDAO.CheckIn(id, boughtItems); shopItemCodes.RemoveAll(bCode => bCode == id); int count = (int)Session[DataKeys.ShopItemsCount]; Session[DataKeys.ShopItemsCount] = count - boughtItems; }