public DynamicText SaveDynamicText( DynamicText dynamicText, IfDefaultNotExistAction actionForDefaultCulture = IfDefaultNotExistAction.DoNothing ) { var dictionaryScope = GetDictionaryScope(dynamicText.DictionaryScope); if (dictionaryScope.Name != dynamicText.DictionaryScope) { m_dictionaryScopeUoW.AddScope(dynamicText.DictionaryScope); dictionaryScope = GetDictionaryScope(dynamicText.DictionaryScope); } var culture = GetCultureByNameOrGetDefault(dynamicText.Culture); if (culture.Name != dynamicText.Culture) { throw new ArgumentException($"Unknown culture {dynamicText.Culture}"); } var staticText = m_staticTextUoW.GetByNameAndCultureAndScope( dynamicText.Name, culture.Name, dictionaryScope.Name ); if (staticText == null) { m_staticTextUoW.AddStaticText( dynamicText.Name, dynamicText.Format, dynamicText.Text, culture.Name, dictionaryScope.Name, dynamicText.ModificationUser, DateTime.UtcNow ); } else { m_staticTextUoW.UpdateStaticText( dynamicText.Name, culture.Name, dictionaryScope.Name, dynamicText.Format, dynamicText.Text, dynamicText.ModificationUser, DateTime.UtcNow ); } ExecuteDefaultCultureAction(actionForDefaultCulture, dynamicText, culture, dictionaryScope); return(dynamicText); }
public void StaticTextCreateUpdateTest() { var cultureUoW = new CultureUoW(m_sessionFactory); var dictionaryScopeUoW = new DictionaryScopeUoW(m_sessionFactory); var staticTextUoW = new StaticTextUoW(m_sessionFactory); cultureUoW.AddCulture("cs"); dictionaryScopeUoW.AddScope("dictionaryScope"); var time = DateTime.UtcNow; staticTextUoW.AddStaticText( "name", 0, "text", "cs", "dictionaryScope", "modificationUser", time ); var staticText = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "dictionaryScope" ); Assert.AreEqual("name", staticText.Name); Assert.AreEqual("text", staticText.Text); staticTextUoW.UpdateStaticText( "name", "cs", "dictionaryScope", 0, "modifiedText", "modificationUser", time ); var staticTextReFetched = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "dictionaryScope" ); Assert.AreEqual("modifiedText", staticTextReFetched.Text); }