Beispiel #1
0
        public void AddRule(AccessRules rule)
        {
            var project = this.Projects.SingleOrDefault(x => x.Name == rule.Project);

            if (project == null)
            {
                project = new Project() { Name = rule.Project };

                this.Projects.Add(project);
            }

            var application = project.Applications.SingleOrDefault(x => x.Name == rule.Application);

            if (application == null)
            {
                application = new Application() { Name = rule.Application };

                project.Applications.Add(application);
            }

            if (rule.Cluster == "Defaults")
            {
                if (rule.Access == Access.WriteAccess)
                    application.Access = Access.ReadAcccess | Access.WriteAccess;
                else
                    application.Access = Access.ReadAcccess;
            }
            else
            {
                var cluster = application.Clusters.SingleOrDefault(x => x.Name == rule.Cluster);

                if (cluster == null)
                {
                    cluster = new Cluster() { Name = rule.Cluster };

                    application.Clusters.Add(cluster);
                }

                if (rule.Access == Access.WriteAccess)
                    cluster.Access = Access.ReadAcccess | Access.WriteAccess;
                else
                    cluster.Access = Access.ReadAcccess;
            }
        }
 public DefaultsDTO(Application application, Dictionary<string, string> settings)
 {
     Application = application;
     Settings = settings;
 }