示例#1
0
 public void AddLinkpost(Linkpost linkpost)
 {
     using (var db = new Sova())
     {
         linkpost.linkpostid = db.Linkpost.Max(lp => lp.linkpostid) + 1;
         db.Add(linkpost);
         db.SaveChanges();
     }
 }
示例#2
0
 public void AddPost_tag(Post_tag pt)
 {
     using (var db = new Sova())
     {
         pt.postid = db.Post_tag.Max(p => pt.id) + 1;
         db.Add(pt);
         db.SaveChanges();
     }
 }
示例#3
0
 public void AddHistory(History history)
 {
     using (var db = new Sova())
     {
         history.id = db.HistoryList.Max(h => h.id) + 1;
         db.Add(history);
         db.SaveChanges();
     }
 }
示例#4
0
 public void AddUser(User user)
 {
     using (var db = new Sova())
     {
         user.id = db.User.Max(u => u.id) + 1;
         db.Add(user);
         db.SaveChanges();
     }
 }
示例#5
0
 public void AddComment(Comment comment)
 {
     using (var db = new Sova())
     {
         comment.id = db.Comments.Max(c => c.id) + 1;
         db.Add(comment);
         db.SaveChanges();
     }
 }
示例#6
0
 public void AddPost(Post post)
 {
     using (var db = new Sova())
     {
         post.id = db.Posts.Max(p => p.id) + 1;
         db.Add(post);
         db.SaveChanges();
     }
 }
示例#7
0
 public void AddTags(Tags tags)
 {
     using (var db = new Sova())
     {
         tags.id = db.Tags.Max(ta => ta.id) + 1;
         db.Add(tags);
         db.SaveChanges();
     }
 }
示例#8
0
 public bool DeletePost_tag(int id)
 {
     using (var db = new Sova())
     {
         var post_tag = db.Post_tag.FirstOrDefault(pt => pt.id == id);
         if (post_tag == null)
         {
             return(false);
         }
         db.Remove(post_tag);
         return(db.SaveChanges() > 0);
     }
 }
示例#9
0
 public bool DeleteLinkpost(int id)
 {
     using (var db = new Sova())
     {
         var linkpost = db.Linkpost.FirstOrDefault(lp => lp.linkpostid == id);
         if (linkpost == null)
         {
             return(false);
         }
         db.Remove(linkpost);
         return(db.SaveChanges() > 0);
     }
 }
示例#10
0
 public bool DeleteUser(int id)
 {
     using (var db = new Sova())
     {
         var user = db.User.FirstOrDefault(u => u.id == id);
         if (user == null)
         {
             return(false);
         }
         db.Remove(user);
         return(db.SaveChanges() > 0);
     }
 }
示例#11
0
 public bool DeleteComment(int id)
 {
     using (var db = new Sova())
     {
         var comment = db.Comments.FirstOrDefault(c => c.id == id);
         if (comment == null)
         {
             return(false);
         }
         db.Remove(comment);
         return(db.SaveChanges() > 0);
     }
 }
示例#12
0
 public bool DeleteTags(int id)
 {
     using (var db = new Sova())
     {
         var tags = db.Tags.FirstOrDefault(ta => ta.id == id);
         if (tags == null)
         {
             return(false);
         }
         db.Remove(tags);
         return(db.SaveChanges() > 0);
     }
 }
示例#13
0
        public bool UpdatePost_tag(Post_tag post_tag)
        {
            using (var db = new Sova())

                try
                {
                    db.Attach(post_tag);
                    db.Entry(post_tag).State = EntityState.Modified;
                    return(db.SaveChanges() > 0);
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(false);
                }
        }
示例#14
0
        public bool UpdateLinkpost(Linkpost linkpost)
        {
            using (var db = new Sova())

                try
                {
                    db.Attach(linkpost);
                    db.Entry(linkpost).State = EntityState.Modified;
                    return(db.SaveChanges() > 0);
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(false);
                }
        }
示例#15
0
        public bool UpdateUser(User user)
        {
            using (var db = new Sova())

                try
                {
                    db.Attach(user);
                    db.Entry(user).State = EntityState.Modified;
                    return(db.SaveChanges() > 0);
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(false);
                }
        }