using System; using System.Collections.Generic; using System.Linq; using BS.Shared; namespace BeWo.Data.Entities { public class CostRatePeriod : BeWoEntityBase { public static string PropertyName_CostRateType = "CostRateType"; public static string PropertyName_CostRateValue = "CostRateValue"; public static string PropertyName_EndDate = "EndDate"; public static string PropertyName_ObjectOid = "ObjectOid"; public static string PropertyName_ObjectTid = "ObjectTid"; public static string PropertyName_StartDate = "StartDate"; public static string PropertyName_UnitName = "UnitName"; public static string PropertyName_ValueListEntry = "ValueListEntry"; private CostRatePeriodType _CostRateType; private decimal? _CostRateValue; private DateTime? _EndDate; private long? _ObjectOid; private TableID _ObjectTid; private DateTime? _StartDate; private string _UnitName; private ValueListEntry _ValueListEntry; public virtual CostRatePeriodType CostRateType { get { return this._CostRateType; } set { if (this.AreDifferent(this._CostRateType, value)) { this._CostRateType = value; } } } public virtual decimal? CostRateValue { get { return this._CostRateValue; } set { if (this.AreDifferent(this._CostRateValue, value)) { this._CostRateValue = value; } } } public virtual DateTime? EndDate { get { return this._EndDate; } set { if (this.AreDifferent(this._EndDate, value)) { this._EndDate = value; } } } public virtual long? ObjectOid { get { return this._ObjectOid; } set { if (this.AreDifferent(this._ObjectOid, value)) { this._ObjectOid = value; } } } public virtual TableID ObjectTid { get { return this._ObjectTid; } set { if (this._ObjectTid != value) { this._ObjectTid = value; } } } public virtual DateTime? StartDate { get { return this._StartDate; } set { if (this.AreDifferent(this._StartDate, value)) { this._StartDate = value; } } } public virtual string UnitName { get { return this._UnitName; } set { if (this.AreDifferent(this._UnitName, value)) { this._UnitName = value; } } } public virtual ValueListEntry ValueListEntry { get { return this._ValueListEntry; } set { if (this.AreDifferent(this._ValueListEntry, value)) { this._ValueListEntry = value; } } } //public static CostRatePeriod GetValidServiceUnitForDate(IList costRates, DateTime date) //{ // if (costRates == null) // { // return null; // } // var serviceUnits = costRates.Where(i => i.CostRateType == CostRatePeriodType.MinutesPerServiceUnit && i.CostRateValue.HasValue && !string.IsNullOrEmpty(i.UnitName)); // return serviceUnits.Where(i => i.EndDate.HasValue).OrderBy(i => i.EndDate).FirstOrDefault(i => i.EndDate >= date) ?? serviceUnits.SingleOrDefault(i => !i.EndDate.HasValue); //} //public virtual decimal GetMinutesInBE(decimal minutes) //{ // return minutes / this.CostRateValue.Value; //} //public virtual decimal GetBEInMinutes(decimal be) //{ // return be * CostRateValue.Value; //} } }