⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shoppingcartline.cs

📁 ibatis源码及帮助文档(IBatis源码+xsd+帮助)
💻 CS
字号:

using System;

using NPetshop.Domain.Catalog;

namespace NPetshop.Domain.Shopping
{

	[Serializable]
	public class ShoppingCartLine  
	{
		#region Private Fields
		private Item _item = null;
		private bool _isInStock = false;
		private int _quantity = -1;
		private decimal _total = 0;
		#endregion
		
		#region Constructors
		public ShoppingCartLine(Item item)
		{
			this.Item = item;
			this.Quantity = 1;
		}

		public ShoppingCartLine(Item item, int quantity)
		{
			this.Item = item;
			this.Quantity = quantity;
		}
		#endregion

		#region Properties 
		public Item Item 
		{
			get { return _item; }
			set 
			{ 
				_item = value; 
				CalculateTotal();
			}
		}

		public int Quantity
		{
			get { return _quantity; }
			set 
			{ 
				_quantity = value;
				CalculateTotal();
			}
		}

		public bool IsInStock
		{
			get { return _isInStock; }
			set { _isInStock = value; }
		}

		public decimal Total 
		{
			get { return _total; }
		}

		#endregion

		#region Public methods
		public void IncrementQuantity() 
		{
			_quantity++;
			CalculateTotal();
		}
		#endregion

		#region Private methods
		private void CalculateTotal()
		{
			if (_item != null) 
			{
				_total = _quantity * _item.ListPrice; 
			}
			else 
			{
				_total = 0;
			}
		}
		#endregion

	}
}

⌨️ 快捷键说明

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