Example #1
0
        public static void AddOrUpdate(string rawVideoId, CommentResponse commentRes)
        {
            using (var db = new NicoVideoDbContext())
            {
                var comment = db.Comments.SingleOrDefault(x => x.ThreadId == rawVideoId);

                if (comment == null)
                {
                    comment = new NicoVideoComment()
                    {
                        ThreadId     = rawVideoId,
                        CommentCount = commentRes.GetCommentCount()
                    };

                    db.Comments.Add(comment);
                }
                else
                {
                    comment.CommentCount = commentRes.GetCommentCount();
                    comment.SetComments(commentRes.Chat);

                    db.Comments.Update(comment);
                }

                db.SaveChanges();
            }
        }
Example #2
0
 public static void Remove(UserInfo info)
 {
     using (var db = new NicoVideoDbContext())
     {
         db.Users.Remove(info);
         db.SaveChanges();
     }
 }
Example #3
0
 public static void Remove(string rawVideoId)
 {
     using (var db = new NicoVideoDbContext())
     {
         var comment = db.Comments.SingleOrDefault(x => x.ThreadId == rawVideoId);
         if (comment != null)
         {
             db.Comments.Remove(comment);
             db.SaveChanges();
         }
     }
 }
Example #4
0
        public static void Deleted(string rawVideoId)
        {
            using (var db = new NicoVideoDbContext())
            {
                var info = db.VideoInfos.SingleOrDefault(x => x.RawVideoId == rawVideoId);

                if (info != null)
                {
                    info.IsDeleted = true;
                    db.VideoInfos.Update(info);
                    db.SaveChanges();
                }
            }
        }
Example #5
0
        public static void Remove(string rawVideoId)
        {
            var nicoVideoInfo = Get(rawVideoId);

            if (nicoVideoInfo == null)
            {
                return;
            }

            using (var db = new NicoVideoDbContext())
            {
                db.VideoInfos.Remove(nicoVideoInfo);
                db.SaveChanges();
            }
        }