Beispiel #1
0
        public string GetUrlPropertyStringValue(Object @object)
        {
            foreach (Member member in this.requestHandler.Storage.GetRepository <IMemberRepository>().FilteredByClassIdInlcudingParent(@object.ClassId).ToList())
            {
                if (member.Code == "Url")
                {
                    Property property = this.requestHandler.Storage.GetRepository <IPropertyRepository>().WithObjectIdAndMemberId(@object.Id, member.Id);

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

                    Culture      neutralCulture = CultureManager.GetNeutralCulture(this.requestHandler.Storage);
                    Localization localization   = null;

                    if (neutralCulture != null)
                    {
                        localization = this.requestHandler.Storage.GetRepository <ILocalizationRepository>().WithDictionaryIdAndCultureId((int)property.StringValueId, neutralCulture.Id);
                    }

                    return(localization?.Value);
                }
            }

            return(null);
        }
Beispiel #2
0
        private SerializedObject SerializeObject(Culture culture, Object @object)
        {
            Class   @class         = this.requestHandler.Storage.GetRepository <IClassRepository>().WithKey(@object.ClassId);
            Culture neutralCulture = CultureManager.GetNeutralCulture(this.requestHandler.Storage);
            List <SerializedProperty> serializedProperties = new List <SerializedProperty>();

            foreach (Member member in this.requestHandler.Storage.GetRepository <IMemberRepository>().FilteredByClassIdInlcudingParent(@class.Id))
            {
                if (member.PropertyDataTypeId != null)
                {
                    Property property = this.requestHandler.Storage.GetRepository <IPropertyRepository>().WithObjectIdAndMemberId(@object.Id, member.Id);

                    serializedProperties.Add(this.SerializeProperty(member.IsPropertyLocalizable == true ? culture : neutralCulture, property));
                }
            }

            SerializedObject serializedObject = new SerializedObject();

            serializedObject.ObjectId  = @object.Id;
            serializedObject.CultureId = culture.Id;
            serializedObject.UrlPropertyStringValue = serializedProperties.FirstOrDefault(sp => sp.Member.Code == "Url")?.StringValue;

            if (serializedProperties.Count != 0)
            {
                serializedObject.SerializedProperties = this.SerializeObject(serializedProperties);
            }

            return(serializedObject);
        }
Beispiel #3
0
        public PropertyViewModel Create(Property property)
        {
            Member  member         = this.RequestHandler.Storage.GetRepository <IMemberRepository>().WithKey(property.MemberId);
            Culture neutralCulture = CultureManager.GetNeutralCulture(this.RequestHandler.Storage);

            return(new PropertyViewModel()
            {
                MemberCode = member.Code,
                Html = member.IsPropertyLocalizable == true?this.GetLocalizationValue(property.HtmlId) : this.GetLocalizationValue(property.HtmlId, neutralCulture.Id)
            });
        }
Beispiel #4
0
        public IEnumerable <string> GetDisplayProperties(Object @object)
        {
            List <string> properties     = new List <string>();
            Culture       neutralCulture = CultureManager.GetNeutralCulture(this.requestHandler.Storage);
            Culture       defaultCulture = CultureManager.GetDefaultCulture(this.requestHandler.Storage);

            if (defaultCulture != null)
            {
                foreach (Member member in this.requestHandler.Storage.GetRepository <IMemberRepository>().FilteredByClassIdInlcudingParentPropertyVisibleInList(@object.ClassId).ToList())
                {
                    Property property = this.requestHandler.Storage.GetRepository <IPropertyRepository>().WithObjectIdAndMemberId(@object.Id, member.Id);

                    if (property == null)
                    {
                        properties.Add(string.Empty);
                    }

                    else
                    {
                        Localization localization = null;

                        if (member.IsPropertyLocalizable == true && defaultCulture != null)
                        {
                            localization = this.requestHandler.Storage.GetRepository <ILocalizationRepository>().WithDictionaryIdAndCultureId((int)property.StringValueId, defaultCulture.Id);
                        }

                        else if (neutralCulture != null)
                        {
                            localization = this.requestHandler.Storage.GetRepository <ILocalizationRepository>().WithDictionaryIdAndCultureId((int)property.StringValueId, neutralCulture.Id);
                        }

                        if (localization == null)
                        {
                            properties.Add(string.Empty);
                        }

                        else
                        {
                            properties.Add(localization.Value);
                        }
                    }
                }
            }

            return(properties);
        }
Beispiel #5
0
        private SerializedProperty SerializeProperty(Culture culture, Property property)
        {
            SerializedProperty serializedProperty = new SerializedProperty();
            Member             member             = this.requestHandler.Storage.GetRepository <IMemberRepository>().WithKey(property.MemberId);
            DataType           dataType           = this.requestHandler.Storage.GetRepository <IDataTypeRepository>().WithKey((int)member.PropertyDataTypeId);
            SerializedMember   serializedMember   = new SerializedMember();

            serializedMember.Code = member.Code;
            serializedMember.PropertyDataTypeStorageDataType = dataType.StorageDataType;
            serializedProperty.Member = serializedMember;

            if (dataType.StorageDataType == StorageDataType.Integer)
            {
                serializedProperty.IntegerValue = property.IntegerValue;
            }

            else if (dataType.StorageDataType == StorageDataType.Decimal)
            {
                serializedProperty.DecimalValue = property.DecimalValue;
            }

            else if (dataType.StorageDataType == StorageDataType.String)
            {
                Culture neutralCulture = CultureManager.GetNeutralCulture(requestHandler.Storage);
                string  stringValue    = member.IsPropertyLocalizable == true?
                                         this.requestHandler.GetLocalizationValue((int)property.StringValueId, culture.Id) : this.requestHandler.GetLocalizationValue((int)property.StringValueId, neutralCulture.Id);

                serializedProperty.StringValue = stringValue;
            }

            else if (dataType.StorageDataType == StorageDataType.DateTime)
            {
                serializedProperty.DateTimeValue = property.DateTimeValue;
            }

            return(serializedProperty);
        }
        private dynamic CreateObjectViewModel(IRequestHandler requestHandler, Object @object)
        {
            ViewModelBuilder viewModelBuilder = new ViewModelBuilder();

            foreach (var property in requestHandler.Storage.GetRepository <IPropertyRepository>().FilteredByObjectId(@object.Id))
            {
                Member   member   = requestHandler.Storage.GetRepository <IMemberRepository>().WithKey(property.MemberId);
                DataType dataType = requestHandler.Storage.GetRepository <IDataTypeRepository>().WithKey((int)member.PropertyDataTypeId);

                if (dataType.StorageDataType == StorageDataType.Integer)
                {
                    viewModelBuilder.BuildProperty(member.Code, property.IntegerValue);
                }

                else if (dataType.StorageDataType == StorageDataType.Decimal)
                {
                    viewModelBuilder.BuildProperty(member.Code, property.DecimalValue);
                }

                else if (dataType.StorageDataType == StorageDataType.String)
                {
                    Culture neutralCulture = CultureManager.GetNeutralCulture(requestHandler.Storage);
                    string  stringValue    = member.IsPropertyLocalizable == true?
                                             requestHandler.GetLocalizationValue((int)property.StringValueId) : requestHandler.GetLocalizationValue((int)property.StringValueId, neutralCulture.Id);

                    viewModelBuilder.BuildProperty(member.Code, stringValue);
                }

                else if (dataType.StorageDataType == StorageDataType.DateTime)
                {
                    viewModelBuilder.BuildProperty(member.Code, property.DateTimeValue);
                }
            }

            return(viewModelBuilder.Build());
        }