/// <summary>
        /// Updates the localized property
        /// </summary>
        /// <param name="localizedProperty">Localized property</param>
        public virtual void UpdateLocalizedProperty(LocalizedProperty localizedProperty)
        {
            if (localizedProperty == null)
            {
                throw new ArgumentNullException(nameof(localizedProperty));
            }

            _localizedPropertyRepository.Update(localizedProperty);

            //event notification
            _eventPublisher.EntityUpdated(localizedProperty);
        }
Beispiel #2
0
        /// <summary>
        /// Deletes a localized property
        /// </summary>
        /// <param name="localizedProperty">Localized property</param>
        public virtual void DeleteLocalizedProperty(LocalizedProperty localizedProperty)
        {
            if (localizedProperty == null)
            {
                throw new ArgumentNullException("localizedProperty");
            }

            _localizedPropertyRepository.Delete(localizedProperty);

            //cache
            _cacheManager.RemoveByPattern(LOCALIZEDPROPERTY_PATTERN_KEY);
        }
Beispiel #3
0
        /// <summary>
        /// Updates the localized property
        /// </summary>
        /// <param name="localizedProperty">Localized property</param>
        public virtual void UpdateLocalizedProperty(LocalizedProperty localizedProperty)
        {
            if (localizedProperty == null)
            {
                throw new ArgumentNullException(nameof(localizedProperty));
            }

            _localizedPropertyRepository.Update(localizedProperty);

            //cache
            _cacheManager.RemoveByPattern(NopLocalizationDefaults.LocalizedPropertyPatternCacheKey);
        }
        public void UpdateLocalizedProperty(LocalizedProperty localizedProperty)
        {
            if (localizedProperty == null)
            {
                throw new ArgumentNullException("localizedProperty");
            }

            //_localizedPropertyRepository.(localizedProperty);
            _unitOfWork.Complete();

            //cache
            _cacheManager.RemoveByPattern(LOCALIZEDPROPERTY_PATTERN_KEY);
        }
Beispiel #5
0
        /// <summary>
        /// Updates the localized property
        /// </summary>
        /// <param name="localizedProperty">Localized property</param>
        public virtual void UpdateLocalizedProperty(LocalizedProperty localizedProperty)
        {
            if (localizedProperty == null)
            {
                throw new ArgumentNullException("localizedProperty");
            }

            _localizedPropertyCollection.Update(Query.EQ("_id", localizedProperty.Id),
                                                Update <LocalizedProperty> .Replace(localizedProperty));

            //cache
            _cacheManager.RemoveByPattern(LOCALIZEDPROPERTY_PATTERN_KEY);
        }
Beispiel #6
0
        /// <summary>
        /// </summary>
        /// <param name="localizedProperty"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public virtual void InsertLocalizedProperty(LocalizedProperty localizedProperty)
        {
            if (localizedProperty == null)
            {
                throw new ArgumentNullException(nameof(localizedProperty));
            }

            using (var client = DbFactory.GetClient())
            {
                client.Insertable(localizedProperty).ExecuteCommand();
            }

            //_cacheManager.Remove<AddPolicy>();
        }
        public IActionResult InsertLocalizedProperty([FromBody] LocalizedProperty model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            //var entity = model.ToEntity();
            var entity = model;

            entity.Id = 0;
            _localizedEntityService.InsertLocalizedProperty(entity);

            return(NoContent());
        }
        public IActionResult Post(LocalizedProperty model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }


            //save it and respond
            _localizedPropertyService.Insert(model);

            VerboseReporter.ReportSuccess("Thêm ngôn ngữ thành công", "post");
            return(RespondSuccess(model));
        }
        public virtual void DeleteLocalizedProperty(LocalizedProperty property)
        {
            Guard.NotNull(property, nameof(property));

            try
            {
                // cache
                ClearCachedPropertySegment(property.LocaleKeyGroup, property.LocaleKey, property.EntityId, property.LanguageId);
            }
            catch { }

            // db
            _localizedPropertyRepository.Delete(property);
            HasChanges = true;
        }
        public virtual void DeleteLocalizedProperty(LocalizedProperty localizedProperty)
        {
            Guard.ArgumentNotNull(() => localizedProperty);

            try
            {
                // cache
                var    key = GenerateKey(localizedProperty);
                string val = null;
                GetAllProperties().TryRemove(key, out val);

                // db
                _localizedPropertyRepository.Delete(localizedProperty);
            }
            catch { }
        }
Beispiel #11
0
        /// <summary>
        /// </summary>
        /// <param name="localizedProperty"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public virtual void UpdateLocalizedProperty(LocalizedProperty localizedProperty)
        {
            if (localizedProperty == null)
            {
                throw new ArgumentNullException(nameof(localizedProperty));
            }

            using (var client = DbFactory.GetClient())
            {
                client.Updateable(localizedProperty).ExecuteCommand();
            }

            var key =
                $"{localizedProperty.LanguageId}_{localizedProperty.EntityId}_{localizedProperty.LocaleKeyGroup}_{localizedProperty.LocaleKey}";
            //_cacheManager.Remove<UpdatePolicy>(key);
        }
        public IActionResult Put(LocalizedProperty entityModel)
        {
            var localizedProperty = _localizedPropertyService.FirstOrDefault(x => x.Id == entityModel.Id);

            //save it and respond

            localizedProperty.LocaleKey   = entityModel.LocaleKey;
            localizedProperty.LocaleValue = entityModel.LocaleValue;
            localizedProperty.LanguageId  = entityModel.LanguageId;

            _localizedPropertyService.Update(localizedProperty);

            VerboseReporter.ReportSuccess("Sửa ngôn ngữ thành công", "post");

            return(RespondSuccess(localizedProperty));
        }
Beispiel #13
0
        private void TranslateMetaKeywords(NopProduct nopProduct)
        {
            foreach (var googleLanguage in GoogleLanguage.Languages)
            {
                if (googleLanguage.Id != 1)
                {
                    string translatedText = null;
                    if (googleLanguage.Id == 2)
                    {
                        translatedText =
                            @"保健品 维生素 抗衰老 医药 在线 护理 健康 美容 产品 减肥 处方药 药物 扑热息痛 皮肤 流感 阿司匹林 奶粉 婴儿食品 母婴用品 儿童 男人 女人 老人 小孩 自然 有机";
                    }
                    else
                    {
                        var keywords = nopProduct.MetaKeywords.Replace(" ", "/ ");
                        var language = GoogleLanguage.GetLanguageById(googleLanguage.Id);



                        if (language != null && googleLanguage.Id != 1)
                        {
                            translatedText = NopDictionary.GetTranslate(keywords, googleLanguage.Id);

                            if (string.IsNullOrWhiteSpace(translatedText))
                            {
                                translatedText = Translator.Translate(keywords, "English", GoogleLanguage.GetLanguageById(googleLanguage.Id).Name);

                                translatedText = translatedText.Replace("/", " ");
                            }
                        }
                    }


                    var lan = new LocalizedProperty
                    {
                        EntityId       = nopProduct.Id,
                        LanguageId     = googleLanguage.Id,
                        LocaleKey      = "MetaKeywords",
                        LocaleKeyGroup = "Prodcut",
                        LocaleValue    = translatedText
                    };

                    LocalizedEntityService.InsertLocalizedProperty(lan);
                }
            }
        }
        public virtual void UpdateLocalizedProperty(LocalizedProperty localizedProperty)
        {
            Guard.ArgumentNotNull(() => localizedProperty);

            try
            {
                // db
                _localizedPropertyRepository.Update(localizedProperty);

                // cache
                var key = GenerateKey(localizedProperty);
                var val = localizedProperty.LocaleValue.EmptyNull();
                GetAllProperties().AddOrUpdate(
                    key,
                    val,
                    (k, v) => val);
            }
            catch { }
        }
        /// <summary>
        /// Inserts a localized property
        /// </summary>
        /// <param name="localizedProperty">Localized property</param>
        public virtual void Insert(LocalizedProperty value)
        {
            //if (localizedProperty == null)
            //	throw new ArgumentNullException("localizedProperty");

            //_localizedPropertyRepository.Insert(localizedProperty);

            ////cache
            //_cacheManager.RemoveByPattern(LOCALIZEDPROPERTY_PATTERN_KEY);

            using (var scope = _dbContextScopeFactory.Create())
            {
                var dbContext = scope.DbContexts
                                .Get <ApplicationDbContext>();

                dbContext.Set <LocalizedProperty>().Add(value);

                scope.SaveChanges();
            }
        }
        public void InvalidateCache(LocalizedProperty localizedProperty, CacheInvalidationOperation operation)
        {
            var item = _mapper.Map <LocalizedProperty, LocalizedPropertyCached>(localizedProperty);

            var success = _cacheManager.TryUpdate(LocalizationCacheKeys.LocalizedPropertyAllCacheKey, LocalizationCacheKeys.LocalizedPropertyCacheRegion, list =>
            {
                switch (operation)
                {
                case CacheInvalidationOperation.Add:
                    list.Add(item);
                    break;

                case CacheInvalidationOperation.Update:
                    var updateIndex   = list.FindIndex(p => p.Id == item.Id);
                    list[updateIndex] = item;
                    break;

                case CacheInvalidationOperation.Delete:
                    var removeIndex = list.FindIndex(p => p.Id == item.Id);
                    list.RemoveAt(removeIndex);
                    break;
                }
                return(list);
            }, out var _);

            if (!success)
            {
                _cacheManager.ClearRegion(LocalizationCacheKeys.LocalizedPropertyCacheRegion);
            }

            success = _updateCacheManagerString(item, operation);
            if (!success)
            {
                _cacheManagerString.ClearRegion(LocalizationCacheKeys.LocalizedPropertyCacheRegion);
            }
        }
        /// <summary>
        /// Deletes a localized property
        /// </summary>
        /// <param name="localizedProperty">Localized property</param>
        public virtual void Delete(LocalizedProperty localizedProperty)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var dbContext = scope.DbContexts
                                .Get <ApplicationDbContext>();

                var existed = dbContext.Set <LocalizedProperty>()
                              .SingleOrDefault(item => item.ID == localizedProperty.ID);

                if (existed != null)
                {
                    dbContext.Set <LocalizedProperty>().Remove(existed);
                    scope.SaveChanges();
                }
            }
            //if (localizedProperty == null)
            //	throw new ArgumentNullException("localizedProperty");

            //_localizedPropertyRepository.Delete(localizedProperty);

            ////cache
            //_cacheManager.RemoveByPattern(LOCALIZEDPROPERTY_PATTERN_KEY);
        }
        public virtual void SaveLocalizedValue <T, TPropType>(T entity,
                                                              Expression <Func <T, TPropType> > keySelector,
                                                              TPropType localeValue,
                                                              int languageId) where T : IEntity, ILocalizedEntity
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            if (languageId == 0)
            {
                throw new ArgumentOutOfRangeException("languageId", "Language ID should not be 0");
            }

            var member = keySelector.Body as MemberExpression;

            if (member == null)
            {
                throw new ArgumentException(string.Format(
                                                "Expression '{0}' refers to a method, not a property.",
                                                keySelector));
            }

            var propInfo = member.Member as PropertyInfo;

            if (propInfo == null)
            {
                throw new ArgumentException(string.Format(
                                                "Expression '{0}' refers to a field, not a property.",
                                                keySelector));
            }

            string localeKeyGroup = typeof(T).Name;
            string localeKey      = propInfo.Name;

            var props = GetLocalizedProperties(entity.ID, localeKeyGroup);
            var prop  = props.FirstOrDefault(lp => lp.LanguageId == languageId &&
                                             lp.LocaleKey.Equals(localeKey, StringComparison.InvariantCultureIgnoreCase)); //should be culture invariant

            var localeValueStr = CommonHelper.To <string>(localeValue);

            if (prop != null)
            {
                if (string.IsNullOrWhiteSpace(localeValueStr))
                {
                    //delete
                    Delete(prop);
                }
                else
                {
                    //update
                    prop.LocaleValue = localeValueStr;
                    Update(prop);
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(localeValueStr))
                {
                    //insert
                    prop = new LocalizedProperty
                    {
                        EntityId       = entity.ID,
                        LanguageId     = languageId,
                        LocaleKey      = localeKey,
                        LocaleKeyGroup = localeKeyGroup,
                        LocaleValue    = localeValueStr
                    };
                    Insert(prop);
                }
            }
        }
Beispiel #19
0
		public override object CreateCustomizationObject()
		{
			if (!HasProperties)
				return null;
			LocalizedTypeDescriptor localizedTypeDescriptor = new LocalizedTypeDescriptor();
			foreach (TemplateProperty property in Properties) {
				LocalizedProperty localizedProperty;
				if (property.Type.StartsWith("Types:")) {
					localizedProperty = new LocalizedProperty(property.Name, "System.Enum", property.Category, property.Description);
					TemplateType type = null;
					foreach (TemplateType templateType in CustomTypes) {
						if (templateType.Name == property.Type.Substring("Types:".Length)) {
							type = templateType;
							break;
						}
					}
					if (type == null) {
						throw new Exception("type : " + property.Type + " not found.");
					}
					localizedProperty.TypeConverterObject = new CustomTypeConverter(type);
					StringParserPropertyContainer.LocalizedProperty["Properties." + localizedProperty.Name] = property.DefaultValue;
					localizedProperty.DefaultValue = property.DefaultValue; // localizedProperty.TypeConverterObject.ConvertFrom();
				} else {
					localizedProperty = new LocalizedProperty(property.Name, property.Type, property.Category, property.Description);
					if (property.Type == "System.Boolean") {
						localizedProperty.TypeConverterObject = new BooleanTypeConverter();
						string defVal = property.DefaultValue == null ? null : property.DefaultValue.ToString();
						if (defVal == null || defVal.Length == 0) {
							defVal = "True";
						}
						StringParserPropertyContainer.LocalizedProperty["Properties." + localizedProperty.Name] = defVal;
						localizedProperty.DefaultValue = Boolean.Parse(defVal);
					} else {
						string defVal = property.DefaultValue == null ? String.Empty : property.DefaultValue.ToString();
						StringParserPropertyContainer.LocalizedProperty["Properties." + localizedProperty.Name] = defVal;
						localizedProperty.DefaultValue = defVal;
					}
				}
				localizedProperty.LocalizedName = property.LocalizedName;
				localizedTypeDescriptor.Properties.Add(localizedProperty);
			}
			return localizedTypeDescriptor;
		}
        public virtual void SaveLocalizedValue <T, TPropType>(
            T entity,
            Expression <Func <T, TPropType> > keySelector,
            TPropType localeValue,
            int languageId) where T : BaseEntity, ILocalizedEntity
        {
            Guard.NotNull(entity, nameof(entity));
            Guard.NotZero(languageId, nameof(languageId));

            var member = keySelector.Body as MemberExpression;

            if (member == null)
            {
                throw new ArgumentException($"Expression '{keySelector}' refers to a method, not a property.");
            }

            var propInfo = member.Member as PropertyInfo;

            if (propInfo == null)
            {
                throw new ArgumentException($"Expression '{keySelector}' refers to a field, not a property.");
            }

            var keyGroup = typeof(T).Name;
            var key      = propInfo.Name;
            var valueStr = localeValue.Convert <string>();
            var prop     = GetLocalizedProperty(languageId, entity.Id, keyGroup, key);

            if (prop != null)
            {
                if (valueStr.IsEmpty())
                {
                    // delete
                    DeleteLocalizedProperty(prop);
                }
                else
                {
                    // update
                    if (prop.LocaleValue != valueStr)
                    {
                        prop.LocaleValue = valueStr;
                        UpdateLocalizedProperty(prop);
                    }
                }
            }
            else
            {
                if (valueStr.HasValue())
                {
                    // insert
                    prop = new LocalizedProperty
                    {
                        EntityId       = entity.Id,
                        LanguageId     = languageId,
                        LocaleKey      = key,
                        LocaleKeyGroup = keyGroup,
                        LocaleValue    = valueStr
                    };
                    InsertLocalizedProperty(prop);
                }
            }
        }
 public static LocalizedPropertyDTO ToModel(this LocalizedProperty entity)
 {
     return(entity.MapTo <LocalizedProperty, LocalizedPropertyDTO>());
 }
 /// <summary>
 /// Deletes a localized property
 /// </summary>
 /// <param name="localizedProperty">Localized property</param>
 protected virtual async Task DeleteLocalizedPropertyAsync(LocalizedProperty localizedProperty)
 {
     await _localizedPropertyRepository.DeleteAsync(localizedProperty);
 }
 /// <summary>
 /// Updates the localized property
 /// </summary>
 /// <param name="localizedProperty">Localized property</param>
 public virtual void UpdateLocalizedProperty(LocalizedProperty localizedProperty)
 {
     _localizedPropertyRepository.Update(localizedProperty);
 }
 /// <summary>
 /// Inserts a localized property
 /// </summary>
 /// <param name="localizedProperty">Localized property</param>
 public virtual void InsertLocalizedProperty(LocalizedProperty localizedProperty)
 {
     _localizedPropertyRepository.Insert(localizedProperty);
 }
Beispiel #25
0
        public void SaveLocalizedValue <T, TPropType>(T entity, Expression <Func <T, TPropType> > keySelector, TPropType localeValue, int languageId) where T : BaseEntity, ILocalizedEntity
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            if (languageId == 0)
            {
                throw new ArgumentOutOfRangeException("languageId 不能为0");
            }

            var member = keySelector.Body as MemberExpression;

            if (member == null)
            {
                throw new ArgumentException(string.Format("表达式{0}应为属性或字段的访问器", keySelector));
            }

            var proInfo = member.Member as PropertyInfo;

            if (proInfo == null)
            {
                throw new ArgumentException(string.Format("表达式{0}应为属性或字段的访问器", keySelector));
            }

            string localeKeyGroup = typeof(T).Name;
            string localeKey      = proInfo.Name;
            var    props          = GetLocalizedProperties(entity.Id, localeKeyGroup);
            var    prop           = props.FirstOrDefault(m => m.LanguageId == languageId && m.LocaleKey.Equals(localeKey, StringComparison.InvariantCultureIgnoreCase));

            var localeValueStr = CommonHelper.To <string>(localeValue);

            if (prop != null)
            {
                if (string.IsNullOrWhiteSpace(localeValueStr))
                {
                    DeleteLocalizedProperty(prop);
                }
                else
                {
                    prop.LocaleValue = localeValueStr;
                    UpdateLocalizedProperty(prop);
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(localeValueStr))
                {
                    prop = new LocalizedProperty()
                    {
                        EntityId       = entity.Id,
                        LanguageId     = languageId,
                        LocaleKey      = localeKey,
                        LocaleKeyGroup = localeKeyGroup,
                        LocaleValue    = localeValueStr
                    };
                    InsertLocalizedProperty(prop);
                }
            }
        }
 private string GenerateKey(LocalizedProperty prop)
 {
     return(GenerateKey(prop.LanguageId, prop.LocaleKeyGroup, prop.LocaleKey, prop.EntityId));
 }
 /// <summary>
 /// Deletes a localized property
 /// </summary>
 /// <param name="localizedProperty">Localized property</param>
 public virtual void DeleteLocalizedProperty(LocalizedProperty localizedProperty)
 {
     _localizedPropertyRepository.Delete(localizedProperty);
 }
        private bool HasAliasDuplicate(LocalizedProperty property)
        {
            var existingProperties = _localizedPropertyRepository.Value.Table.Where(x =>
                                                                                    x.Id != property.Id &&
                                                                                    x.LocaleKey == "Alias" &&
                                                                                    x.LocaleKeyGroup == property.LocaleKeyGroup &&
                                                                                    x.LanguageId == property.LanguageId &&
                                                                                    x.LocaleValue == property.LocaleValue).ToList();

            if (existingProperties.Count == 0)
            {
                // Check cases where alias has to be globally unique.
                string otherKeyGroup = null;

                if (property.LocaleKeyGroup.IsCaseInsensitiveEqual("SpecificationAttribute"))
                {
                    otherKeyGroup = "ProductAttribute";
                }
                else if (property.LocaleKeyGroup.IsCaseInsensitiveEqual("ProductAttribute"))
                {
                    otherKeyGroup = "SpecificationAttribute";
                }

                if (otherKeyGroup.HasValue())
                {
                    existingProperties = _localizedPropertyRepository.Value.Table.Where(x =>
                                                                                        x.LocaleKey == "Alias" &&
                                                                                        x.LocaleKeyGroup == otherKeyGroup &&
                                                                                        x.LanguageId == property.LanguageId &&
                                                                                        x.LocaleValue == property.LocaleValue).ToList();
                }

                if (existingProperties.Count == 0)
                {
                    return(false);
                }
            }

            var toDelete = new List <LocalizedProperty>();

            foreach (var prop in existingProperties)
            {
                // Check if the related entity exists. The user would not be able to solve an invalidated alias when the related entity does not exist anymore.
                var relatedEntityExists = true;

                if (prop.LocaleKeyGroup.IsCaseInsensitiveEqual("SpecificationAttribute"))
                {
                    relatedEntityExists = _ctx.Resolve <IRepository <SpecificationAttribute> >().GetById(prop.EntityId) != null;
                }
                else if (prop.LocaleKeyGroup.IsCaseInsensitiveEqual("SpecificationAttributeOption"))
                {
                    relatedEntityExists = _ctx.Resolve <IRepository <SpecificationAttributeOption> >().GetById(prop.EntityId) != null;
                }
                else if (prop.LocaleKeyGroup.IsCaseInsensitiveEqual("ProductAttribute"))
                {
                    relatedEntityExists = _ctx.Resolve <IRepository <ProductAttribute> >().GetById(prop.EntityId) != null;
                }
                else if (prop.LocaleKeyGroup.IsCaseInsensitiveEqual("ProductAttributeOption"))
                {
                    relatedEntityExists = _ctx.Resolve <IRepository <ProductAttributeOption> >().GetById(prop.EntityId) != null;
                }
                //else if (prop.LocaleKeyGroup.IsCaseInsensitiveEqual("ProductVariantAttributeValue"))
                //{
                //	relatedEntityExists = _ctx.Resolve<IRepository<ProductVariantAttributeValue>>().GetById(prop.EntityId) != null;
                //}

                if (relatedEntityExists)
                {
                    // We cannot delete any localized property because we are going to throw duplicate alias exception in OnBeforeSaveCompleted.
                    return(true);
                }
                else
                {
                    // Delete accidentally dead localized properties.
                    toDelete.Add(prop);
                }
            }

            if (toDelete.Any())
            {
                try
                {
                    _localizedPropertyRepository.Value.DeleteRange(toDelete);
                }
                catch (Exception exception)
                {
                    exception.Dump();
                }
            }

            return(false);
        }
 public static void Insert(LocalizedProperty pNew)
 {
     BNBDataContext.Instance.LocalizedProperties.InsertOnSubmit(pNew);
     BNBDataContext.Instance.SubmitChanges();
 }
Beispiel #30
0
        /// <summary>
        /// Save localized value
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <typeparam name="TPropType">Property type</typeparam>
        /// <param name="entity">Entity</param>
        /// <param name="keySelector">Key selector</param>
        /// <param name="localeValue">Locale value</param>
        /// <param name="languageId">Language ID</param>
        public virtual void SaveLocalizedValue <T, TPropType>(T entity,
                                                              Expression <Func <T, TPropType> > keySelector,
                                                              TPropType localeValue,
                                                              int languageId) where T : BaseEntity, ILocalizedEntity
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (languageId == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(languageId), "Language ID should not be 0");
            }

            if (!(keySelector.Body is MemberExpression member))
            {
                throw new ArgumentException(string.Format(
                                                "Expression '{0}' refers to a method, not a property.",
                                                keySelector));
            }

            var propInfo = member.Member as PropertyInfo;

            if (propInfo == null)
            {
                throw new ArgumentException(string.Format(
                                                "Expression '{0}' refers to a field, not a property.",
                                                keySelector));
            }

            //load localized value (check whether it's a cacheable entity. In such cases we load its original entity type)
            var localeKeyGroup = entity.GetUnproxiedEntityType().Name;
            var localeKey      = propInfo.Name;

            var props = GetLocalizedProperties(entity.Id, localeKeyGroup);
            var prop  = props.FirstOrDefault(lp => lp.LanguageId == languageId &&
                                             lp.LocaleKey.Equals(localeKey, StringComparison.InvariantCultureIgnoreCase)); //should be culture invariant

            var localeValueStr = CommonHelper.To <string>(localeValue);

            if (prop != null)
            {
                if (string.IsNullOrWhiteSpace(localeValueStr))
                {
                    //delete
                    DeleteLocalizedProperty(prop);
                }
                else
                {
                    //update
                    prop.LocaleValue = localeValueStr;
                    UpdateLocalizedProperty(prop);
                }
            }
            else
            {
                if (string.IsNullOrWhiteSpace(localeValueStr))
                {
                    return;
                }

                //insert
                prop = new LocalizedProperty
                {
                    EntityId       = entity.Id,
                    LanguageId     = languageId,
                    LocaleKey      = localeKey,
                    LocaleKeyGroup = localeKeyGroup,
                    LocaleValue    = localeValueStr
                };
                InsertLocalizedProperty(prop);
            }
        }
 /// <summary>
 /// Inserts a localized property
 /// </summary>
 /// <param name="localizedProperty">Localized property</param>
 protected virtual async Task InsertLocalizedPropertyAsync(LocalizedProperty localizedProperty)
 {
     await _localizedPropertyRepository.InsertAsync(localizedProperty);
 }