Exemple #1
0
        public DataAttributeModel()
        {
            Id = 0;
            Name = "";
            ShortName = "";
            Description = "";
            InUse = false;
            ShowConstraints = false;

            DataType = new DataTypeItemModel();
            Unit = new UnitItemModel();

            dataTypeManager.Repo.Get().OrderBy(dt => dt.Name).ToList().ForEach(dt => DataTypes.Add(new DataTypeItemModel(dt)));
            unitManager.Repo.Get().OrderBy(u => u.Name).ToList().ForEach(u => Units.Add(new UnitItemModel(u)));

            RangeConstraints = new List<RangeConstraintModel>();
            DomainConstraints = new List<DomainConstraintModel>();
            PatternConstraints = new List<PatternConstraintModel>();
        }
Exemple #2
0
        public DataAttributeModel(DataAttribute dataAttribute, bool showConstraints = false)
        {
            Id = dataAttribute.Id;
            Name = dataAttribute.Name;
            ShortName = dataAttribute.ShortName;
            Description = dataAttribute.Description;
            ShowConstraints = showConstraints;

            DataType = new DataTypeItemModel(dataAttribute.DataType);
            Unit = new UnitItemModel(dataAttribute.Unit);

            dataTypeManager.Repo.Get().OrderBy(dt => dt.Name).ToList().ForEach(dt => DataTypes.Add(new DataTypeItemModel(dt)));
            unitManager.Repo.Get().OrderBy(u => u.Name).ToList().ForEach(u => Units.Add(new UnitItemModel(u)));

            RangeConstraints = new List<RangeConstraintModel>();
            DomainConstraints = new List<DomainConstraintModel>();
            PatternConstraints = new List<PatternConstraintModel>();

            dataAttribute.Constraints.ToList().Where(c => c.GetType().Equals(typeof(RangeConstraint))).ToList().ForEach(rc => RangeConstraints.Add(RangeConstraintModel.Convert((RangeConstraint)rc, Id)));
            dataAttribute.Constraints.ToList().Where(c => c.GetType().Equals(typeof(PatternConstraint))).ToList().ForEach(pc => PatternConstraints.Add(PatternConstraintModel.Convert((PatternConstraint)pc, Id)));
            dataAttribute.Constraints.ToList().Where(c => c.GetType().Equals(typeof(DomainConstraint))).ToList().ForEach(dc => DomainConstraints.Add(DomainConstraintModel.Convert((DomainConstraint)dc, Id)));

            if (dataAttribute.UsagesAsVariable != null && dataAttribute.UsagesAsVariable.Count > 0)
                InUse = true;

            if (dataAttribute.Constraints.Count > 0)
            {
                foreach (Constraint c in dataAttribute.Constraints)
                {
                    if (c is RangeConstraint)
                    {
                        RangeConstraints.Add(RangeConstraintModel.Convert((RangeConstraint)c, Id));
                    }
                    if (c is PatternConstraint)
                    {
                        PatternConstraints.Add(PatternConstraintModel.Convert((PatternConstraint)c, Id));
                    }

                    if (c is DomainConstraint)
                    {
                        DomainConstraints.Add(DomainConstraintModel.Convert((DomainConstraint)c, Id));
                    }
                }
            }
        }