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(); } }
public static void Remove(UserInfo info) { using (var db = new NicoVideoDbContext()) { db.Users.Remove(info); db.SaveChanges(); } }
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(); } } }
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(); } } }
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(); } }