Esempio n. 1
0
        public static void inserts(string blogId, List <string> categoryIds)
        {
            DataBaseBlog db = new DataBaseBlog();

            foreach (string categoryId in categoryIds)
            {
                Blog_category bc = new Blog_category();
                bc.ID          = Guid.NewGuid().ToString();
                bc.blog_id     = blogId;
                bc.category_id = categoryId;
                db.Blog_category.Add(bc);
            }
            db.SaveChanges();
        }
Esempio n. 2
0
        public static void Update(string blogId, List <string> categoryIds)
        {
            DataBaseBlog db = new DataBaseBlog();

            db.Blog_category.RemoveRange(db.Blog_category.Where(b => b.blog_id == blogId));
            foreach (string categoryId in categoryIds)
            {
                Blog_category bc = new Blog_category();
                bc.ID          = Guid.NewGuid().ToString();
                bc.blog_id     = blogId;
                bc.category_id = categoryId;
                db.Blog_category.Add(bc);
            }
            db.SaveChanges();
        }