/// <summary> /// Gets the VED details by derivate id /// </summary> /// <param name="derivId">The derivative id</param> /// <returns>The VED Details set</returns> public List <IVEDDetailsSet> GetVEDDetailsByDerivId(int derivId) { List <IVEDDetailsSet> results = new List <IVEDDetailsSet>(); Sproc procedure = new Sproc("VED_S", DatabaseName); procedure.Parameters.Add("@CARDerId", SqlDbType.Int).Value = derivId; using (SqlDataReader reader = procedure.ExecuteReader()) { if (reader.HasRows) { VEDDetailsSet currentSet = null; while (reader.Read()) { IVEDDetails ved = GetVEDFromDataReader(reader); if (currentSet == null || ved.EffectivePeriod != currentSet.EffectivePeriod) { currentSet = new VEDDetailsSet { EffectivePeriod = ved.EffectivePeriod }; results.Add(currentSet); } currentSet.Values.Add(ved); if (ved.FirstYearApplies) { currentSet.FirstYearApplies = true; } } } } foreach (IVEDDetailsSet item in results) { item.CombineResults(); } return(results); }
public void Combine(IVEDDetails other) { if (other.StartDate < this.StartDate) { this.StartDate = other.StartDate; } if (other.EndDate > this.EndDate) { this.EndDate = other.EndDate; } if (other.CO2Min < this.CO2Min) { this.CO2Min = other.CO2Min; } if (other.CO2Max > this.CO2Max) { this.CO2Max = other.CO2Max; } }