예제 #1
0
        public string AddRetentionPolicy(string tenantName, string productName, string componentName, ComponentRetention retention)
        {
            List <TenantConfiguration> tenants = TenantIOReader.ReadTenantsFromConfigFile();
            var tenant = tenants.Find(x => x.Name == tenantName);

            if (tenant == null)
            {
                return(null);
            }

            var product = tenant.Products.Find(x => x.Name == productName);

            if (product == null)
            {
                return(null);
            }

            var component = product.Components.Find(x => x.Name == componentName);

            if (component == null)
            {
                return(null);
            }


            component.Settings.RetentionPolicy = retention;
            // store token in memory!
            _tenantRepository.AddComponentRetention(tenantName, productName, componentName, retention);

            // Write into file
            if (TenantIOWriter.WriteTenantsConfiguration(tenants) == true)
            {
                return(retention.Name);
            }

            return(null);
        }