inventory.cs

来自「ASP.net网站开发四“酷”全书:新闻、论坛、电子商城、博客_源码」· CS 代码 · 共 47 行

CS
47
字号
using System;

//References to PetShop specific libraries
//PetShop DAL interfaces
using BookShop.IDAL;
using BookShop.Model;

namespace BookShop.BLL{

	/// <summary>
	/// A business component to manage the inventory management for an item
	/// </summary>
	public class Inventory{

		/// <summary>
		/// A method to get the current quanity in stock for an individual item
		/// </summary>
		/// <param name="itemId">A unique identifier for an item</param>
		/// <returns>Current in quantity in stock</returns>
		public int CurrentQuantityInStock(string itemId){

			// Validate input
			if (itemId.Trim() == string.Empty)
				return 0;
			
			// Get an instance of the Inventory DAL using the DALFactory
			IInventory dal = BookShop.DALFactory.Inventory.Create();

			// Query the DAL for the current quantity in stock
			return dal.CurrentQtyInStock(itemId);
		}

		/// <summary>
		/// Reduce the current quantity in stock for an order's lineitems
		/// </summary>
		/// <param name="items">An array of order line items</param>
		public void TakeStock(LineItemInfo[] items){

			// Get an instance of the Inventory DAL using the DALFactory
			IInventory dalc = BookShop.DALFactory.Inventory.Create();

			// Reduce the stock level in the data store
			dalc.TakeStock(items);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?