Esempio n. 1
0
        public void DeleteByBlog(int blogId)
        {
            var postList = context.Posts.Where(p => p.BlogID == blogId).ToList();

            foreach (var post in postList)
            {
                context.Posts.Remove(post);
            }
            context.SaveChanges();
        }
Esempio n. 2
0
        public void DeleteByUser(int user_id)
        {
            var topics = context.TopicFollows.Where(tf => tf.UserID == user_id);

            foreach (var topic in topics)
            {
                context.TopicFollows.Remove(topic);
            }

            context.SaveChanges();
        }
Esempio n. 3
0
        public void CountViews(int blogid)
        {
            var viewcount = context.Blogs.Where(u => u.BlogID == blogid).Select(p => p.ViewCount).ToArray();

            viewcount[0]++;
            var col = context.Blogs.Where(u => u.BlogID == blogid);

            foreach (var item in col)
            {
                item.ViewCount = viewcount[0];
            }
            context.SaveChanges(); // TODO : WHY IS THIS NEEDED  ??
        }
Esempio n. 4
0
 public void Insert(TEntity entity)
 {
     context.Set <TEntity>().Add(entity);
     context.SaveChanges();
 }