public static string PrepareUrl(JGN_Wiki entity) { string _title = ""; if (entity.term_complete == null && entity.term_complete == "") { _title = entity.term; } else { _title = entity.term_complete; } int maxium_length = Settings.Configs.GeneralSettings.maximum_dynamic_link_length; if (_title.Length > maxium_length && maxium_length > 0) { _title = _title.Substring(0, maxium_length); } else if (_title.Length < 3) { _title = "preview-post"; } _title = UtilityBLL.ReplaceSpaceWithHyphin_v2(_title.Trim().ToLower()); return(Config.GetUrl("wiki/" + _title)); }
public static async Task <bool> Delete(ApplicationDbContext context, int id) { var entity = new JGN_Wiki { id = id }; context.JGN_Wiki.Attach(entity); context.JGN_Wiki.Remove(entity); await context.SaveChangesAsync(); return(true); }
public static JGN_Wiki Add(ApplicationDbContext context, JGN_Wiki entity) { // string content = UtilityBLL.Add_NoFollow_Tag(entity.description); string content = Scripts.UGeneral.SanitizeText(entity.description, false); content = Process_WikiLinks_v2(context, content); if (entity.id == 0) { var _entity = new JGN_Wiki() { userid = entity.userid, replyid = entity.replyid, tags = entity.tags, term = entity.term, term_complete = entity.term_complete, description = content, created_at = DateTime.Now, }; context.Entry(_entity).State = EntityState.Added; context.SaveChanges(); entity.id = _entity.id; } else { var item = context.JGN_Wiki .Where(p => p.id == entity.id) .FirstOrDefault(); if (item != null) { item.term = entity.term; item.term_complete = entity.term_complete; item.description = content; item.tags = entity.tags; item.updated_at = DateTime.Now; context.SaveChanges(); } } return(entity); }