private void CreateLocalizations(PropertyInfo propertyInfo, Dictionary dictionary) { IEnumerable<Culture> cultures = this.Storage.GetRepository<ICultureRepository>().All(); foreach (Culture culture in cultures) { Localization localization = new Localization(); localization.DictionaryId = dictionary.Id; localization.CultureId = culture.Id; string identity = propertyInfo.Name + culture.Code; string value = this.Request.Form[identity]; localization.Value = value; this.Storage.GetRepository<ILocalizationRepository>().Create(localization); } this.Storage.Save(); }
protected IEnumerable<Platformus.Barebone.Backend.Localization> GetLocalizations(Dictionary dictionary = null) { List<Platformus.Barebone.Backend.Localization> localizations = new List<Platformus.Barebone.Backend.Localization>(); foreach (Platformus.Globalization.Data.Models.Culture culture in this.handler.Storage.GetRepository<ICultureRepository>().All()) { Platformus.Globalization.Data.Models.Localization localization = null; if (dictionary != null) localization = this.handler.Storage.GetRepository<ILocalizationRepository>().FilteredByDictionaryId(dictionary.Id).FirstOrDefault(l => l.CultureId == culture.Id); localizations.Add( new Platformus.Barebone.Backend.Localization( new Platformus.Barebone.Backend.Culture(culture.Code), localization == null ? null : localization.Value ) ); } return localizations; }
private void CreateProperty(Object @object, int memberId, string cultureCode, string value) { Property property = this.Storage.GetRepository<IPropertyRepository>().WithObjectIdAndMemberId(@object.Id, memberId); if (property == null) { Dictionary html = new Dictionary(); this.Storage.GetRepository<IDictionaryRepository>().Create(html); this.Storage.Save(); property = new Property(); property.ObjectId = @object.Id; property.MemberId = memberId; property.HtmlId = html.Id; this.Storage.GetRepository<IPropertyRepository>().Create(property); this.Storage.Save(); } Localization localization = new Localization(); localization.DictionaryId = property.HtmlId; localization.CultureId = this.Storage.GetRepository<ICultureRepository>().WithCode(cultureCode).Id; localization.Value = value; this.Storage.GetRepository<ILocalizationRepository>().Create(localization); }
private void DeleteLocalizations(Dictionary dictionary) { foreach (Localization localization in this.Storage.GetRepository<ILocalizationRepository>().FilteredByDictionaryId(dictionary.Id)) this.Storage.GetRepository<ILocalizationRepository>().Delete(localization); this.Storage.Save(); }
private Dictionary GetOrCreateDictionaryForProperty(IEntity entity, PropertyInfo propertyInfo) { PropertyInfo dictionaryIdPropertyInfo = entity.GetType().GetProperty(propertyInfo.Name + "Id"); int dictionaryId = (int)dictionaryIdPropertyInfo.GetValue(entity); Dictionary dictionary = null; if (dictionaryId == 0) { dictionary = new Dictionary(); this.Storage.GetRepository<IDictionaryRepository>().Create(dictionary); this.Storage.Save(); dictionaryIdPropertyInfo.SetValue(entity, dictionary.Id); } else dictionary = this.Storage.GetRepository<IDictionaryRepository>().WithKey(dictionaryId); return dictionary; }