示例#1
0
 public static IReadOnlyList <uint> GetNgVideoOwnerIds()
 {
     using (var db = new NgDbContext())
     {
         return(db.NgVideoOwnerUser.Select(x => x.UserId).ToList());
     }
 }
示例#2
0
 public static IReadOnlyList <string> GetNgVideoTitleList()
 {
     using (var db = new NgDbContext())
     {
         return(db.NgVideoTitleKeyword.Select(x => x.Keyword).ToList());
     }
 }
示例#3
0
 public static IReadOnlyList <string> GetNgVideoTagList()
 {
     using (var db = new NgDbContext())
     {
         return(db.NgVideoTag.Select(x => x.Tag).ToList());
     }
 }
示例#4
0
            public static void AddNgVideoTitle(string keyword)
            {
                using (var db = new NgDbContext())
                {
                    db.NgVideoTitleKeyword.Add(new NgVideoTitleKeyword()
                    {
                        Keyword = keyword
                    });

                    db.SaveChanges();
                }
            }
示例#5
0
 public static void RemoveNgVideoOwnerId(uint userId)
 {
     using (var db = new NgDbContext())
     {
         var removeTarget = db.NgVideoOwnerUser.SingleOrDefault(x => x.UserId == userId);
         if (removeTarget != null)
         {
             db.NgVideoOwnerUser.Remove(removeTarget);
             db.SaveChanges();
         }
     }
 }
示例#6
0
            public static void AddNgVideoOwnerId(uint userId)
            {
                using (var db = new NgDbContext())
                {
                    db.NgVideoOwnerUser.Add(new NgVideoOwnerUser()
                    {
                        UserId = userId
                    });

                    db.SaveChanges();
                }
            }
示例#7
0
 public static void RemoveNgVideoTag(string tag)
 {
     using (var db = new NgDbContext())
     {
         var removeTarget = db.NgVideoTag.SingleOrDefault(x => x.Tag == tag);
         if (removeTarget != null)
         {
             db.NgVideoTag.Remove(removeTarget);
             db.SaveChanges();
         }
     }
 }
示例#8
0
            public static void AddNgVideoTag(string tag)
            {
                using (var db = new NgDbContext())
                {
                    db.NgVideoTag.Add(new NgVideoTag()
                    {
                        Tag = tag
                    });

                    db.SaveChanges();
                }
            }
示例#9
0
 public static void RemoveNgVideoTitle(string keyword)
 {
     using (var db = new NgDbContext())
     {
         var removeTarget = db.NgVideoTitleKeyword.SingleOrDefault(x => x.Keyword == keyword);
         if (removeTarget != null)
         {
             db.NgVideoTitleKeyword.Remove(removeTarget);
             db.SaveChanges();
         }
     }
 }
示例#10
0
        public static NGResult IsNgVideo(string videoTitle, uint userId, IList <Tag> tags)
        {
            using (var db = new NgDbContext())
            {
                if (db.NgVideoOwnerUser.Any(x => x.UserId == userId))
                {
                    return(new NGResult()
                    {
                        NGReason = NGReason.UserId,
                        NGDescription = "",
                        Content = userId.ToString(),
                    });
                }

                var titleNg = db.NgVideoTitleKeyword.FirstOrDefault(x => 0 != videoTitle.IndexOf(x.Keyword));
                if (titleNg != null)
                {
                    return(new NGResult()
                    {
                        NGReason = NGReason.Keyword,
                        Content = titleNg.Keyword,
                    });
                }

                var tagNg = db.NgVideoTag.FirstOrDefault(x => tags.Any(y => y.Value == x.Tag && (x.IgNgOnlyLock && y.Lock)));
                if (tagNg != null)
                {
                    return(new NGResult()
                    {
                        NGReason = NGReason.Tag,
                        Content = tagNg.Tag + (tagNg.IgNgOnlyLock ? "(Lock)" : ""),
                    });
                }

                return(null);
            }
        }