public virtual async Task UpdateAsync( Material material, string tags, CategoryCached category) { IHtmlDocument doc = new HtmlParser().Parse(material.Text); material.Text = sanitizer.Sanitize(doc); var generator = categoriesCache.GetMaterialsPreviewGenerator(category.MaterialsPreviewGeneratorName); material.Preview = generator(doc, materialsOptions.PreviewLength); switch (category.MaterialsSubTitleInputType) { case MaterialsSubTitleInputType.Manual: material.SubTitle = SimpleHtmlToText.ClearTags(sanitizer.Sanitize(material.SubTitle)); break; case MaterialsSubTitleInputType.Auto: material.SubTitle = MakeSubTitle.Do(doc, materialsOptions.SubTitleLength); break; default: material.SubTitle = null; break; } await db.UpdateAsync(material); await tagsManager.MaterialCreateAndSetTagsAsync(material, tags); }
public virtual async ValueTask CreateAsync(Material material, string tags, CategoryCached category) { IHtmlDocument doc = new HtmlParser().Parse(material.Text); material.Text = sanitizerService.Sanitize(doc); material.SettingsJson = material.SettingsJson?.MakeJsonText(); switch (category.MaterialsSubTitleInputType) { case MaterialsSubTitleInputType.Manual: material.SubTitle = SimpleHtmlToText.ClearTags(sanitizerService.Sanitize(material.SubTitle)); break; case MaterialsSubTitleInputType.Auto: material.SubTitle = MakeSubTitle.Do(doc, materialsOptions.SubTitleLength); break; } using (db.BeginTransaction()) { material.Id = await db.InsertWithInt32IdentityAsync(material); await db.Materials.Where(x => x.Id == material.Id).Set(x => x.SortNumber, x => material.Id) .UpdateAsync(); await tagsManager.MaterialCreateAndSetTagsAsync(material, tags); db.CommitTransaction(); } }
public virtual async ValueTask CreateAsync( Material material, string tags, CategoryCached category, IReadOnlyDictionary <string, RoleCached> roles) { if (!roles.ContainsKey(RoleNames.Admin) || sanitizerService.SanitizerOptions.SanitizeAdminMaterials) { material.Text = sanitizerService.Sanitize(new HtmlParser().ParseDocument(material.Text)); } material.SettingsJson = material.SettingsJson?.MakeJsonText(); if (category.IsMaterialsSubTitleEditable) { material.SubTitle = SimpleHtmlToText.ClearTags(sanitizerService.Sanitize(material.SubTitle)); } using (db.BeginTransaction()) { material.Id = await db.InsertWithInt32IdentityAsync(material); await db.Materials.Where(x => x.Id == material.Id).Set(x => x.SortNumber, x => material.Id) .UpdateAsync(); await tagsManager.MaterialCreateAndSetTagsAsync(material, tags); db.CommitTransaction(); } }
public virtual async ValueTask UpdateAsync( Material material, string tags, CategoryCached category) { IHtmlDocument doc = new HtmlParser().Parse(material.Text); material.Text = sanitizerService.Sanitize(doc); material.SettingsJson = material.SettingsJson?.MakeJsonText(); switch (category.MaterialsSubTitleInputType) { case MaterialsSubTitleInputType.Manual: material.SubTitle = SimpleHtmlToText.ClearTags(sanitizerService.Sanitize(material.SubTitle)); break; case MaterialsSubTitleInputType.Auto: material.SubTitle = MakeSubTitle.Do(doc, materialsOptions.SubTitleLength); break; default: material.SubTitle = null; break; } await db.UpdateAsync(material); await tagsManager.MaterialCreateAndSetTagsAsync(material, tags); }
public virtual async Task UpdateAsync(Material material, string tags, bool isDescriptionEditable = false) { material.Text = sanitizer.Sanitize(material .Text); // TODO сделать совместную валидацию, санитайзин и превью на основе одного DOM var(preview, description) = MaterialExtensions.MakePreviewAndDescription(material.Text, materialsOptions.DescriptionLength, materialsOptions.PreviewLength); material.Preview = preview; if (isDescriptionEditable) { material.Description = SimpleHtmlToText.ClearTags(sanitizer.Sanitize(material.Description)); } else { material.Description = description; } /*material.MakePreviewAndDescription(materialsOptions.DescriptionLength, * materialsOptions.PreviewLength);*/ await db.UpdateAsync(material); await tagsManager.MaterialCreateAndSetTagsAsync(material, tags); }
public virtual async Task CreateAsync(Material material, string tags, bool isDescriptionEditable = false) { material.Text = sanitizer.Sanitize(material.Text); var(preview, description) = MaterialExtensions.MakePreviewAndDescription(material.Text, materialsOptions.DescriptionLength, materialsOptions.PreviewLength); material.Preview = preview; if (isDescriptionEditable) { material.Description = SimpleHtmlToText.ClearTags(sanitizer.Sanitize(material.Description)); } else { material.Description = description; } /*material.MakePreviewAndDescription(materialsOptions.DescriptionLength, * materialsOptions.PreviewLength);*/ material.Id = await db.InsertWithInt32IdentityAsync(material); await tagsManager.MaterialCreateAndSetTagsAsync(material, tags); }
public virtual async Task CreateAsync( Material material, string tags, bool isDescriptionEditable = false) { material.Text = sanitizer.Sanitize(material.Text); var(preview, description) = MaterialExtensions.MakePreviewAndDescription(material.Text, materialsOptions.DescriptionLength, materialsOptions.PreviewLength); material.Preview = preview; if (isDescriptionEditable) { material.Description = SimpleHtmlToText.ClearTags(sanitizer.Sanitize(material.Description)); } else { material.Description = description; } using (db.BeginTransaction()) { material.Id = await db.InsertWithInt32IdentityAsync(material); await db.Materials.Where(x => x.Id == material.Id).Set(x => x.SortNumber, x => material.Id) .UpdateAsync(); await tagsManager.MaterialCreateAndSetTagsAsync(material, tags); db.CommitTransaction(); } }
private Task <MaterialSearchInfoView[]> searchMaterialsMySql(string searchString) { return(db.Materials.Where(x => Sql.Ext.MySql().Match(searchString, x.Title, x.Text)) .OrderByDescending(x => x.Id) .Select(x => new MaterialSearchInfoView() { Id = x.Id, Title = x.Title, Text = SimpleHtmlToText.ClearTags(x.Text) }).ToArrayAsync()); }
public virtual async ValueTask UpdateAsync( Material material, string tags, CategoryCached category) { IHtmlDocument doc = new HtmlParser().Parse(material.Text); material.Text = sanitizerService.Sanitize(doc); material.SettingsJson = material.SettingsJson?.MakeJsonText(); if (category.IsMaterialsSubTitleEditable) { material.SubTitle = SimpleHtmlToText.ClearTags(sanitizerService.Sanitize(material.SubTitle)); } await db.UpdateAsync(material); await tagsManager.MaterialCreateAndSetTagsAsync(material, tags); }
public virtual async ValueTask UpdateAsync( Material material, string tags, CategoryCached category, IReadOnlyDictionary <string, RoleCached> roles) { if (!roles.ContainsKey(RoleNames.Admin) || sanitizerService.SanitizerOptions.SanitizeAdminMaterials) { material.Text = sanitizerService.Sanitize(new HtmlParser().ParseDocument(material.Text)); } material.SettingsJson = material.SettingsJson?.MakeJsonText(); if (category.IsMaterialsSubTitleEditable) { material.SubTitle = SimpleHtmlToText.ClearTags(sanitizerService.Sanitize(material.SubTitle)); } await db.UpdateAsync(material); await tagsManager.MaterialCreateAndSetTagsAsync(material, tags); }