/// <summary> /// Check whether selected database category exist in list of associated returned category list, Usage Case (update record -> if not exist then delete it from db) /// </summary> /// <param name="content_category"></param> /// <param name="categories"></param> /// <returns>bool</returns> private static bool isDbCategoryExist(JGN_CategoryContents content_category, string[] categories) { var isexist = false; foreach (var category in categories) { if (content_category.categoryid.ToString() == category) { isexist = true; } } return(isexist); }
public static void Add(ApplicationDbContext context, JGN_CategoryContents entity) { var _entity = new JGN_CategoryContents() { categoryid = entity.categoryid, contentid = entity.contentid, type = entity.type }; context.Entry(_entity).State = EntityState.Added; context.SaveChanges(); }