Beispiel #1
0
        /// <summary>
        /// Gets the property with specified name for current entity
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="propertyName"></param>
        /// <param name="langId"></param>
        /// <returns></returns>
        public static LocalizedProperty GetLocalizedProperty <T>(this IHasLocalizedProperty <T> entity, string propertyName, int langId) where T : BaseEntity
        {
            var localizedPropertyService = EngineContext.Current.Resolve <ILocalizedPropertyService>();

            return
                (localizedPropertyService.Get(
                     x =>
                     x.LocaleKeyGroup == typeof(T).Name &&
                     x.EntityId == entity.Id &&
                     x.LanguageId == langId &&
                     x.LocaleKey == propertyName,
                     null).FirstOrDefault());
        }
Beispiel #2
0
        /// <summary>
        /// Gets the properties of entity
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="langId"></param>
        /// <returns></returns>
        public static IList <LocalizedProperty> GetLocalizedPropertys <T>(this IHasLocalizedProperty <T> entity, int langId) where T : BaseEntity
        {
            if (entity == null)
            {
                return(null);
            }
            var localizedPropertyService = EngineContext.Current.Resolve <ILocalizedPropertyService>();

            return(localizedPropertyService.Get(
                       x =>
                       x.LocaleKeyGroup == typeof(T).Name &&
                       x.EntityId == entity.Id &&
                       x.LanguageId == langId).ToList());
        }
Beispiel #3
0
        /// <summary>
        /// Gets the property valueas stored
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="propertyName"></param>
        /// <param name="langId"></param>
        /// <returns></returns>
        public static object GetLocalizedPropertyValue <T>(this IHasLocalizedProperty <T> entity, string propertyName, int langId) where T : BaseEntity
        {
            var localizedProperty = GetLocalizedProperty(entity, propertyName, langId);

            return(localizedProperty?.LocaleValue);
        }