예제 #1
0
        public override void Initialise(string groupName, Item questionItem, SignupApiResponse response)
        {
            base.Initialise(groupName, questionItem, response);

            if (groupName == "supplyAddress" && questionItem.Name == "knownAddress")
            {
                //lets map meta data so we can hide display the meter numbers for the selected address
                if (response.SupplyAddressSearchResults != null)
                {
                    AcceptableItems.ForEach(i =>
                    {
                        var result = response.SupplyAddressSearchResults.FirstOrDefault(s => s.Id == i.Id);

                        if (result != null)
                        {
                            i.MetaData = JsonConvert.SerializeObject(new
                            {
                                gasMeterKnown         = result.KnownGasMeter,
                                electricityMeterKnown = result.KnownElectricityMeter,
                                igt = result.IGTWarning
                            });
                        }
                    });
                }
            }

            Dynamic = (questionItem.Type.Equals("linked"));
        }
예제 #2
0
        public override void Initialise(string groupName, Item questionItem, SignupApiResponse response)
        {
            base.Initialise(groupName, questionItem, response);

            HashSet <string> selectedValues = new HashSet <string>();

            if (AcceptableItems != null && questionItem.Data != null && questionItem.Data.GetType() == typeof(JArray))
            {
                foreach (string item in ((JArray)questionItem.Data).Select(selectedItem => selectedItem.Value <string>()).Where(item => selectedValues.Contains(item) == false))
                {
                    selectedValues.Add(item);
                }

                foreach (var acceptableItem in AcceptableItems.Where(acceptableItem => selectedValues.Contains(acceptableItem.Id)))
                {
                    acceptableItem.Data = true;
                }
            }

            Data = null;
        }