/// <summary> /// Prepare tag or label page link /// </summary> /// <param name="entity"></param> /// <param name="path"></param> /// <returns></returns> public static string PrepareUrl(JGN_Tags entity, string path) { var _tag = entity.term; if (_tag == "") { _tag = entity.title; } string query = UtilityBLL.ReplaceSpaceWithHyphin_v2(_tag.Trim().ToLower()); return(Config.GetUrl(path + "label/" + query)); }
public static bool Delete(ApplicationDbContext context, int id) { var entity = new JGN_Tags { id = id }; context.JGN_Tags.Attach(entity); context.JGN_Tags.Remove(entity); context.SaveChanges(); return(true); }
// Core function to process content related tags public static void Process_Tags(ApplicationDbContext context, string tags, Types type, TagType tag_type) { if (tags != null) { // process tags var tagItems = tags.ToString().Split(char.Parse(",")); foreach (var JGN_Tags in tagItems) { if (JGN_Tags.Length > 3) { // if JGN_Tags not already exist string term = UtilityBLL.CleanSearchTerm(JGN_Tags.Trim()); if (Count(context, new TagEntity() { title = term, tag_level = TagLevel.All, type = type, isenabled = EnabledTypes.All, tag_type = tag_type }).Result == 0) { // insert each JGN_Tags into tags table int records = 1; // show one record in start by selected JGN_Tags if (tag_type == TagType.UserSearches) { Add(context, JGN_Tags.Trim(), type, records, tag_type, EnabledTypes.Enabled, term); } else { Add(context, JGN_Tags.Trim(), type, records, term); } } else { // JGN_Tags exist - update JGN_Tags records // Due to performance issue, don't enable it on front line. update JGN_Tags statistics from control panel // Process_Records(arr[j].ToString(), type); } } } } }
public static bool Update(ApplicationDbContext context, JGN_Tags entity) { var item = context.JGN_Tags .Where(p => p.id == entity.id) .FirstOrDefault <JGN_Tags>(); if (item != null) { item.title = UtilityBLL.processNull(entity.title, 0); item.isenabled = entity.isenabled; item.tag_level = entity.tag_level; item.tag_type = entity.tag_type; context.Entry(item).State = EntityState.Modified; context.SaveChanges(); } return(true); }
public static bool Add(ApplicationDbContext context, string title, Types type, int records, string term) { if (title == null || title.Length < 3) { return(false); } var _entity = new JGN_Tags() { title = title, type = (byte)type, records = records, term = term }; context.Entry(_entity).State = EntityState.Added; context.SaveChanges(); return(true); }