public LocalizationKeyCollectionEntity CreateAllKeyValues(LocalizationKeyCollectionEntity keyValueSet, bool writeFile = true) { List<LocalizationCollectionEntity> allLocales = Read(); foreach (LocalizationCollectionEntity locale in allLocales) { CreateKeyEntryByNameAndLocale(locale.Locale, keyValueSet.Key, keyValueSet.Key, "", writeFile); } return ReadAllKeyValues(keyValueSet.Key); }
internal static LocalizationKeyCollectionEntity GetLocalizationKeyCollectionToCreate() { LocalizationKeyCollectionEntity collection = new LocalizationKeyCollectionEntity(); collection.Key = Guid.NewGuid().ToString(); LocalizationKeyEntity keyEntity = new LocalizationKeyEntity(); keyEntity.Description = "Some Description"; keyEntity.Locale = "default"; keyEntity.Value = "SomeNewKey"; return collection; }
public LocalizationKeyCollectionEntity UpdateAllKeyValues(LocalizationKeyCollectionEntity keyValueSet, bool writeFile = true) { try { foreach (LocalizationKeyEntity localizationKeyEntity in keyValueSet.KeyValues) { SetKeyValueByNameAndLocale(localizationKeyEntity.Locale, keyValueSet.Key, localizationKeyEntity.Value, localizationKeyEntity.Description); } return ReadAllKeyValues(keyValueSet.Key); } catch (Exception ex) { throw new DataAccessException("Error querying Mongo Database: " + ex.Message); } }
public LocalizationKeyCollectionEntity ReadAllKeyValues(string keyName) { LocalizationKeyCollectionEntity keyValues = new LocalizationKeyCollectionEntity { Key = keyName }; List<LocalizationCollectionEntity> allLocales = Read(); foreach (LocalizationCollectionEntity locale in allLocales) { var keyEntry = GetKeyValueByNameAndLocale(locale, keyName); if (keyEntry != null) keyValues.KeyValues.Add(GetKeyValueByNameAndLocale(locale, keyName)); } if (keyValues.KeyValues.Count == 0) return null; return keyValues; }
private LocalizationKeyDictionary TranslateToKeyResponse(LocalizationKeyCollectionEntity collection) { LocalizationKeyDictionary response = collection.TranslateTo<LocalizationKeyDictionary>(); collection.KeyValues.ForEach(x => response.KeyValues.Add(x.TranslateTo<LocalizationKeyItem>())); return response; }