private void InitializeLinkedValueDrivers() { var selected = SelectedNonKeyDrivers; if (selected != null) { foreach (PricingEverydayValueDriver driver in selected) { PricingEverydayLinkedValueDriver existing = LinkedValueDrivers.FirstOrDefault(d => d.ValueDriverId == driver.Id); if (existing == null) { //var containerItem = ValueDriversCache.Find(i => i.Id == driver.Id); //if (containerItem != null && containerItem.LinkedDriver != null) //{ // LinkedValueDrivers.Add(containerItem.LinkedDriver); //} //else //{ LinkedValueDrivers.Add(new PricingEverydayLinkedValueDriver { ValueDriverId = driver.Id, Name = driver.Name }); //} } } } }
public static DTO.PricingEverydayLinkedValueDriver ToDto(this Display.PricingEverydayLinkedValueDriver displayEntity) { var groups = new List <DTO.PricingEverydayLinkedValueDriverGroup>(); foreach (Display.PricingEverydayLinkedValueDriverGroup group in displayEntity.Groups) { groups.Add(group.ToDto()); } var dto = new DTO.PricingEverydayLinkedValueDriver(displayEntity.ValueDriverId, groups); return(dto); }
public static Display.PricingEverydayLinkedValueDriver ToDisplayEntity(this DTO.PricingEverydayLinkedValueDriver dto) { var displayEntity = new Display.PricingEverydayLinkedValueDriver(); displayEntity.ValueDriverId = dto.ValueDriverId; foreach (DTO.PricingEverydayLinkedValueDriverGroup group in dto.Groups) { displayEntity.Groups.Add(group.ToDisplayEntity()); } displayEntity.IsDirty = false; return(displayEntity); }
private void RecalculateLinkedValueDrivers(PricingEverydayValueDriver driver) { PricingEverydayLinkedValueDriver existing = LinkedValueDrivers.FirstOrDefault(d => d.ValueDriverId == driver.Id); if (driver.IsSelected) { if (existing == null) { PricingEverydayLinkedValueDriver linkedDriver = null; PricingEverydayValueDriverWrapper cachedItem = _valueDriversCache.Find(item => item.Id == driver.Id); if (cachedItem.LinkedDriver != null) { //Get the linked driver from the cache. linkedDriver = cachedItem.LinkedDriver; } else { //Create new linked driver and add it to the cache. linkedDriver = new PricingEverydayLinkedValueDriver { ValueDriverId = driver.Id, Name = driver.Name }; cachedItem.LinkedDriver = linkedDriver; } LinkedValueDrivers.Add(linkedDriver); } } else if (existing != null) { LinkedValueDrivers.Remove(existing); } if (KeyValueDriver != null) { //Remove previously marked key driver from the linked drivers. var keyDriver = LinkedValueDrivers.FirstOrDefault(d => d.ValueDriverId == KeyValueDriver.ValueDriverId); if (keyDriver != null) { LinkedValueDrivers.Remove(keyDriver); } } }