Esempio n. 1
0
 public Tags GetTags(int id)
 {
     using (var db = new Sova())
     {
         return(db.Tags.FirstOrDefault(ta => ta.id == id));
     }
 }
Esempio n. 2
0
 public int GetNumberOfComments()
 {
     using (var db = new Sova())
     {
         return(db.Comments.Count());
     }
 }
Esempio n. 3
0
 public int GetNumberOfPost_tag()
 {
     using (var db = new Sova())
     {
         return(db.Post_tag.Count());
     }
 }
Esempio n. 4
0
 public int GetNumberOfTags()
 {
     using (var db = new Sova())
     {
         return(db.Tags.Count());
     }
 }
Esempio n. 5
0
 public User GetUser(int id)
 {
     using (var db = new Sova())
     {
         return(db.User.FirstOrDefault(c => c.id == id));
     }
 }
Esempio n. 6
0
 public History GetHistory(int id)
 {
     using (var db = new Sova())
     {
         return(db.HistoryList.FirstOrDefault(h => h.id == id));
     }
 }
Esempio n. 7
0
 public int GetNumberOfUser()
 {
     using (var db = new Sova())
     {
         return(db.User.Count());
     }
 }
Esempio n. 8
0
 public Comment GetComment(int id)
 {
     using (var db = new Sova())
     {
         return(db.Comments.FirstOrDefault(c => c.id == id));
     }
 }
Esempio n. 9
0
 public int GetNumberOfLinkpost()
 {
     using (var db = new Sova())
     {
         return(db.Linkpost.Count());
     }
 }
Esempio n. 10
0
 public Linkpost GetLinkpost(int id)
 {
     using (var db = new Sova())
     {
         return(db.Linkpost.FirstOrDefault(lp => lp.linkpostid == id));
     }
 }
Esempio n. 11
0
 public SearchResult GetSearchResult(int id)
 {
     using (var db = new Sova())
     {
         return(db.SearchResults.FirstOrDefault(s => s.id == id));
     }
 }
Esempio n. 12
0
 public int GetCountOfHistoryList()
 {
     using (var db = new Sova())
     {
         return(db.HistoryList.Count());
     }
 }
Esempio n. 13
0
 public Post_tag GetPost_tag(int id)
 {
     using (var db = new Sova())
     {
         return(db.Post_tag.FirstOrDefault(pt => pt.id == id));
     }
 }
Esempio n. 14
0
 public Post GetPost(int id)
 {
     using (var db = new Sova())
     {
         return(db.Posts.FirstOrDefault(p => p.id == id));
     }
 }
Esempio n. 15
0
 public IList <SearchResult> EFShowSearchResult(string searchstring)
 {
     using (var db = new Sova())
     {
         //var conn = (MySqlConnection)db.Database.GetDbConnection();
         //conn.Open();
         //var cmd = new MySqlCommand("call weightingsearch(@searchstring)", conn);
         //cmd.Parameters.Add("@searchstring", DbType.String).Value = searchstring;
         //var reader = cmd.ExecuteReader();
         //var result = new List<SearchResult>();
         //while(reader.HasRows && reader.Read())
         //{
         //    result.Add(new SearchResult
         //    {
         //        id = reader.GetInt32(0),
         //        Title = reader.GetString(2),
         //        body = reader.GetString(3)
         //    });
         //}
         //return result;
         var result = db.Set <SearchResult>()
                      .FromSql("call weightingsearch('" + searchstring + "')");
         foreach (var data in result)
         {
             Console.WriteLine($"{data.id} {data.title} {data.body}");
         }
         return(result.ToList());
     }
 }
Esempio n. 16
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();
     }
 }
Esempio n. 17
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();
     }
 }
Esempio n. 18
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();
     }
 }
Esempio n. 19
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();
     }
 }
Esempio n. 20
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();
     }
 }
Esempio n. 21
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();
     }
 }
Esempio n. 22
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();
     }
 }
Esempio n. 23
0
 public IList <History> GetHistoryList(int page, int pagesize)
 {
     using (var db = new Sova())
     {
         return(db.HistoryList
                .OrderBy(h => h.id)
                .Skip(page * pagesize)
                .ToList());
     }
 }
Esempio n. 24
0
        //User

        public IList <User> GetUser(int page, int pagesize)
        {
            using (var db = new Sova())
            {
                return(db.User
                       .OrderBy(u => u.id)
                       .Skip(page * pagesize)
                       .Take(pagesize)
                       .ToList());
            }
        }
Esempio n. 25
0
 //Post
 public IList <Post> GetPosts(int page, int pagesize)
 {
     using (var db = new Sova())
     {
         return(db.Posts
                .OrderBy(p => p.id)
                .Skip(page * pagesize)
                .Take(pagesize)
                .ToList());
     }
 }
Esempio n. 26
0
 //Post_tag
 public IList <Post_tag> GetPost_tag(int page, int pagesize)
 {
     using (var db = new Sova())
     {
         return(db.Post_tag
                .OrderBy(pt => pt.id)
                .Skip(page * pagesize)
                .Take(pagesize)
                .ToList());
     }
 }
Esempio n. 27
0
 //Comments
 public IList <Comment> GetComments(int page, int pagesize)
 {
     using (var db = new Sova())
     {
         return(db.Comments
                .OrderBy(c => c.id)
                .Skip(page * pagesize)
                .Take(pagesize)
                .ToList());
     }
 }
Esempio n. 28
0
 //Linkpost
 public IList <Linkpost> GetLinkpost(int page, int pagesize)
 {
     using (var db = new Sova())
     {
         return(db.Linkpost
                .OrderBy(lp => lp.linkpostid)
                .Skip(page * pagesize)
                .Take(pagesize)
                .ToList());
     }
 }
Esempio n. 29
0
        //Tags

        public IList <Tags> GetTags(int page, int pagesize)
        {
            using (var db = new Sova())
            {
                return(db.Tags
                       .OrderBy(ta => ta.id)
                       .Skip(page * pagesize)
                       .Take(pagesize)
                       .ToList());
            }
        }
Esempio n. 30
0
 public void EFMarkThisPost(int postid, string searchstring)
 {
     using (var db = new Sova())
     {
         var conn = (MySqlConnection)db.Database.GetDbConnection();
         conn.Open();
         var cmd = new MySqlCommand("call markthispost(@1,@2)", conn);
         cmd.Parameters.Add("@1", DbType.Int64).Value  = postid;
         cmd.Parameters.Add("@2", DbType.String).Value = searchstring;
         Console.WriteLine($"Marked");
     }
 }