using System;
using System.Collections.Generic;
using System.Text;
using Ubik.Engine.Client;
namespace StoresAndStockPricing.Model{
/// <summary>
/// Price of a stock item at a retail store for a time period that is in the past.
/// </summary>
public class StockItemHistoricalSellingPrice : Individual
{
private TrackedReference<StockItem> _stockItem;
private TrackedReference<RetailStore> _retailStore;
private TrackedProperty<decimal> _sellingPrice;
private TrackedProperty<DateTime> _effectiveFrom;
private TrackedProperty<DateTime> _effectiveUntil;
protected StockItemHistoricalSellingPrice(Session session)
: base(session)
{
_stockItem = new TrackedReference<StockItem>(this, "StockItem");
_retailStore = new TrackedReference<RetailStore>(this, "RetailStore");
_sellingPrice = new TrackedProperty<decimal>(this, "SellingPrice");
_effectiveFrom = new TrackedProperty<DateTime>(this, "EffectiveFrom");
_effectiveUntil = new TrackedProperty<DateTime>(this, "EffectiveUntil");
}
public StockItemHistoricalSellingPrice(
Session session,
StockItem stockItem,
RetailStore retailStore,
decimal sellingPrice,
DateTime effectiveFrom
)
: this(session)
{
if (stockItem == null)
throw new ArgumentNullException("stockItem");
if (retailStore == null)
throw new ArgumentNullException("retailStore");
StockItemSellingPrice.ValidateSellingPrice(sellingPrice);
DateTime changeTime = EngineDateTime.UtcNow;
if (effectiveFrom > changeTime)
throw new ArgumentOutOfRangeException("effectiveFrom");
_effectiveFrom.Reset(effectiveFrom);
_effectiveUntil.Reset(changeTime);
_stockItem.Reset(stockItem);
_retailStore.Reset(retailStore);
_sellingPrice.Reset(sellingPrice);
}
public decimal SellingPrice
{
get
{
return _sellingPrice.Value;
}
}
public DateTime EffectiveFrom
{
get
{
return _effectiveFrom.Value;
}
}
public DateTime EffectiveUntil
{
get
{
return _effectiveUntil.Value;
}
}
public RetailStore RetailStore
{
get
{
return _retailStore.Value;
}
}
public StockItem StockItem
{
get
{
return _stockItem.Value;
}
}
}
}
|