public string getValueOrCreateEmpty(string group, string name, string countryCode) { var translation = _translationRepository.Get(group, name); if (translation == null) { translation = new TranslationModel() { GroupName = group, KeyName = name, Values = new List<TranslationValueModel>() }; _translationRepository.Add(translation); } TranslationValueModel result = translation.Values.FirstOrDefault(x => x.CountryCodeId == countryCode); if (result == null){ var newLang = new TranslationValueModel() {CountryCodeId = countryCode, Translation = translation, Value = null}; translation.Values.Add(newLang); return null; } return result.Value; }
public void Add(TranslationModel translation) { _db.Translations.Add(translation); _db.SaveChanges(); }