public static Display.PricingEverydayKeyValueDriver ToDisplayEntity(this DTO.PricingEverydayKeyValueDriver dto) { var displayEntity = new Display.PricingEverydayKeyValueDriver(); displayEntity.ValueDriverId = dto.ValueDriverId; foreach (DTO.PricingEverydayKeyValueDriverGroup group in dto.Groups) { displayEntity.Groups.Add(group.ToDisplayEntity()); } return(displayEntity); }
public static DTO.PricingEverydayKeyValueDriver ToDto(this Display.PricingEverydayKeyValueDriver displayEntity) { var groups = new List <DTO.PricingEverydayKeyValueDriverGroup>(); foreach (Display.PricingEverydayKeyValueDriverGroup group in displayEntity.Groups) { groups.Add(group.ToDto()); } var dto = new DTO.PricingEverydayKeyValueDriver(displayEntity.ValueDriverId, groups); displayEntity.IsDirty = false; return(dto); }
public PricingEveryday() { Identity = new PricingIdentity(); FilterGroups = new ReactiveList <FilterGroup>(); ValueDrivers = new ReactiveList <PricingEverydayValueDriver>(); KeyValueDriver = new PricingEverydayKeyValueDriver(); LinkedValueDrivers = new ObservableCollection <PricingEverydayLinkedValueDriver>(); PricingModes = new List <PricingMode>(); PriceListGroups = new List <PricingEverydayPriceListGroup>(); KeyPriceListRule = new PricingKeyPriceListRule(); LinkedPriceListRules = new List <PricingLinkedPriceListRule>(); Results = new List <PricingEverydayResult>(); _valueDriversCache = new List <PricingEverydayValueDriverWrapper>(); ValueDrivers.ChangeTrackingEnabled = true; _valueDriverChangeListener = ValueDrivers.ItemChanged.Subscribe(driver => OnValueDriverItemChanged(driver)); }
/// <summary> /// Sets this price routine's key value driver to the specified value driver. /// </summary> /// <param name="newKey"></param> public void SetKeyValueDriver(PricingEverydayValueDriver newKey) { PricingEverydayValueDriverWrapper currentKey = null; if (KeyValueDriver != null) { //Clear the current key driver. currentKey = ValueDriversCache.Find(item => item.Id == KeyValueDriver.ValueDriverId); currentKey.IsKey = false; currentKey.IsSelected = false; } //Get the new key driver's item from the cache. PricingEverydayValueDriverWrapper newKeyWrapper = ValueDriversCache.Find(item => item.Id == newKey.Id); newKeyWrapper.IsKey = true; newKeyWrapper.IsSelected = true; if (newKeyWrapper.KeyDriver == null) { //Update the key driver concrete instance in the cache. var keyDriverInstance = new PricingEverydayKeyValueDriver { ValueDriverId = newKey.Id }; foreach (PricingValueDriverGroup sourceGroup in _selectedValueDriver.Groups) { keyDriverInstance.Groups.Add(new PricingEverydayKeyValueDriverGroup { ValueDriverGroupId = sourceGroup.Id, ValueDriverGroupValue = sourceGroup.Value }); } newKeyWrapper.KeyDriver = keyDriverInstance; } KeyValueDriver = newKeyWrapper.KeyDriver; if (SelectedValueDriver != newKeyWrapper.BaseDriver) { SelectedValueDriver = newKeyWrapper.BaseDriver; } }