예제 #1
0
        public IEnumerable <FeatureViewModel> GetAffiliateFeatures(int id)
        {
            var list = new List <FeatureViewModel>();

            foreach (var feature in _affiliateService.GetAffiliateFeatures(id))
            {
                var featureViewModel = new FeatureViewModel()
                {
                    AffiliateFeatureID = feature.AffiliateFeatureID,
                    AffiliateID        = feature.AffiliateID,
                    FeatureID          = feature.FeatureID,
                    IsEnabled          = feature.IsEnabled,
                    Name    = feature.Feature.Name,
                    Tooltip = feature.Feature.Description
                };

                foreach (var setting in feature.Settings)
                {
                    var rawSetting = feature.Feature.Settings.First(s => s.FeatureSettingID == setting.FeatureSettingID);

                    featureViewModel.Settings.Add(new FeatureSettingViewModel()
                    {
                        AffiliateFeatureID = feature.AffiliateFeatureID,
                        FeatureSettingID   = setting.FeatureSettingID,
                        Value           = setting.Value,
                        Name            = rawSetting.Name,
                        Placeholder     = rawSetting.PlaceholderValue,
                        Tooltip         = rawSetting.Description,
                        VisibleState    = rawSetting.VisibleState,
                        IsRequired      = rawSetting.IsRequired,
                        ValidationRegEx = rawSetting.ValidationRegEx
                    });
                }

                list.Add(featureViewModel);
            }

            return(list);
        }