Exemplo n.º 1
0
        private async Task <AbpUserFeatureConfigDto> GetUserFeaturesConfig()
        {
            var config = new AbpUserFeatureConfigDto()
            {
                AllFeatures = new Dictionary <string, AbpStringValueDto>()
            };

            var allFeatures = _featureManager.GetAll().ToList();

            if (_abpSession.TenantId.HasValue)
            {
                var currentTenantId = _abpSession.GetTenantId();
                foreach (var feature in allFeatures)
                {
                    var value = await _featureChecker.GetValueAsync(currentTenantId, feature.Name);

                    config.AllFeatures.Add(feature.Name, new AbpStringValueDto
                    {
                        Value = value
                    });
                }
            }
            else
            {
                foreach (var feature in allFeatures)
                {
                    config.AllFeatures.Add(feature.Name, new AbpStringValueDto
                    {
                        Value = feature.DefaultValue
                    });
                }
            }

            return(config);
        }
        protected virtual Task <AbpUserFeatureConfigDto> GetUserFeaturesConfig()
        {
            var config = new AbpUserFeatureConfigDto()
            {
                AllFeatures = new Dictionary <string, AbpStringValueDto>()
            };

            return(Task.FromResult(config));

            // var allFeatures = FeatureManager.GetAll().ToList();

            // if (AbpSession.TenantId.HasValue)
            // {
            //     var currentTenantId = AbpSession.GetTenantId();
            //     foreach (var feature in allFeatures)
            //     {
            //         var value = await FeatureChecker.GetValueAsync(currentTenantId, feature.Name);
            //         config.AllFeatures.Add(feature.Name, new AbpStringValueDto
            //         {
            //             Value = value
            //         });
            //     }
            // }
            // else
            // {
            //     foreach (var feature in allFeatures)
            //     {
            //         config.AllFeatures.Add(feature.Name, new AbpStringValueDto
            //         {
            //             Value = feature.DefaultValue
            //         });
            //     }
            // }

            // return config;
        }