public static XDocument ToXDocument(NamespaceHelpEntity entity) { return(new XDocument( new XDeclaration("1.0", "utf-8", "yes"), new XElement(_Namespace, new XAttribute(_Name, entity.Name), new XAttribute(_Culture, entity.Culture.Name), entity.Title.HasText() ? new XAttribute(_Title, entity.Title) : null !, entity.Description.HasText() ? new XElement(_Description, entity.Description) : null ! ) )); }
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); } }
public NamespaceHelp(string @namespace, CultureInfo culture, NamespaceHelpEntity entity, Type[] types) { Culture = culture; Namespace = @namespace; Types = types; var clean = @namespace.Replace(".Entities", ""); Title = entity?.Let(a => a.Title.DefaultText(null)) ?? clean.TryAfterLast('.') ?? clean; Before = clean.TryBeforeLast('.'); Description = entity?.Description; Entity = entity ?? new NamespaceHelpEntity { Culture = this.Culture.ToCultureInfoEntity(), Name = this.Namespace }; }
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); }