Example #1
0
 //添加关注
 public void Add(String SourceQQ, String Attention, String GroupNum)
 {
     if (Attention.Contains(" ") || Attention.Equals(""))
     {
         throw new Exception("不允许输入空格和空字符串");
     }
     using (var dbcontext = new AttentionContext())
     {
         Attention newatt = new Attention(SourceQQ, GroupNum, Attention);
         dbcontext.Attentions.Add(newatt);
         dbcontext.SaveChanges();
         this.Attentions = QueryAll();
     }
     UpdateListeners();
 }
Example #2
0
 //删除关注
 public Boolean Remove(String SourceQQ, String Attention, String GroupNum)
 {
     using (var dbcontext = new AttentionContext())
     {
         Attention temp = dbcontext.Attentions.FirstOrDefault(p => p.Listener == SourceQQ && p.Group == GroupNum && p.AttentionPoint == Attention);
         if (temp != null)
         {
             dbcontext.Attentions.Remove(temp);
             dbcontext.SaveChanges();
             this.Attentions = QueryAll();
             UpdateListeners();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }