예제 #1
0
    public void SaveNamespace([Required][FromBody] NamespaceHelpEntity entity)
    {
        HelpPermissions.ViewHelp.AssertAuthorized();

        if (!entity.Title.HasText() && !entity.Description.HasText())
        {
            if (!entity.IsNew)
            {
                entity.ToLite().DeleteLite(NamespaceHelpOperation.Delete);
            }
        }
        else
        {
            entity.Execute(NamespaceHelpOperation.Save);
        }
    }
예제 #2
0
        public static void AsignTranslatedNamespace(this NamespaceHelpEntity @namespace, CultureInfoEntity fromCulture)
        {
            var fromNamespace = Database.Query <NamespaceHelpEntity>().SingleEx(n => n.Name == @namespace.Name && n.Culture == fromCulture);

            HashSet <string> toTranslate = new HashSet <string>();

            if ([email protected]() && fromNamespace.Description.HasText())
            {
                toTranslate.Add(fromNamespace.Description);
            }

            Dictionary <string, string> dic = Translate(toTranslate, fromNamespace.Culture.Name, @namespace.Culture.Name);

            if ([email protected]() && fromNamespace.Description.HasText())
            {
                @namespace.Description = dic.GetOrThrow(fromNamespace.Description);
            }

            @namespace.Execute(NamespaceHelpOperation.Save);
        }