public int GetTotalQuestions()
 {
     using (var db = new MysqlDataContext())
     {
         return(db.Question.Count());
     }
 }
Пример #2
0
 public IList <Comments> GetComments()
 {
     using (var db = new MysqlDataContext())
     {
         return(db.Comment.OrderBy(c => c.CommentCeated).ToList());
     }
 }
 public void AddMarkPost(int postid)
 {
     using (var db = new MysqlDataContext())
     {
         //var cmds = db.MarkedPostStoredProc.FromSql("call insert_markpost({0})", postid);
     }
 }
        public IList <Posts> GetAllMarkedPosts(int page, int pageSize)
        {
            using (var db = new MysqlDataContext())
            {
                var markedid = from m in db.MarkPost
                               select m.PostId;

                var post = (from p in db.Post
                            where markedid.Contains(p.PostsId)
                            select new Posts
                {
                    PostsId = p.PostsId,
                    Body = p.Body,
                    creationDate = p.creationDate,
                    Score = p.Score,
                    PostTypeId = p.PostTypeId,
                    OwnerUserId = p.OwnerUserId
                }).ToList();

                var result = post
                             .OrderBy(m => m.creationDate)
                             .Skip(page * pageSize)
                             .Take(pageSize)
                             .ToList();

                return(result);
            }
        }
 public int GetNumberOfUsers()
 {
     using (var db = new MysqlDataContext())
     {
         return(db.CombineUsers.Count());
     }
 }
 public int GetNumberOfMarkedPosts()
 {
     using (var db = new MysqlDataContext())
     {
         return(db.MarkPost.Count());
     }
 }
 public Comments GetComment(int id)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.Comment.FirstOrDefault(c => c.CommentId == id));
     }
 }
 public CombinedUsers GetCombinedUserById(int id)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.CombineUsers.FirstOrDefault(c => c.CombineUserId == id));
     }
 }
 public IList <Tags> GetTagsById(int id)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.Tags.Where(c => c.PostId == id).ToList());
     }
 }
 public int GetNumberOfTags()
 {
     using (var db = new MysqlDataContext())
     {
         return(db.Tags.Count());
     }
 }
 public int GetTotalLinkPosts()
 {
     using (var db = new MysqlDataContext())
     {
         return(db.LinkPost.Count());
     }
 }
 public Questions GetQuestionbyId(int id)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.Question.FirstOrDefault(q => q.QuestionId == id));
     }
 }
 public int GetTotalHistory()
 {
     using (var db = new MysqlDataContext())
     {
         var count = db.History.Count();
         return(count);
     }
 }
 public Posts GetPost(int id)
 {
     using (var db = new MysqlDataContext())
     {
         var result = db.Post.FirstOrDefault(p => p.PostsId == id);
         return(result);
     }
 }
 public History GetHistory(int id)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.History
                .FirstOrDefault(h => h.HistoryId == id));
     }
 }
 public int GetTotalOwnComments()
 {
     using (var db = new MysqlDataContext())
     {
         var count = db.OwnComment.Count();
         return(count);
     }
 }
 public void AddOwnComment(OwnComments owncomment)
 {
     using (var db = new MysqlDataContext())
     {
         owncomment.CommentId = db.OwnComment.Max(o => o.CommentId) + 1;
         db.Add(owncomment);
         db.SaveChanges();
     }
 }
 public int GetTotalAnswers()
 {
     using (var db = new MysqlDataContext())
     {
         var count = db.Post.Where(p => p.PostTypeId == 2).
                     Count();
         return(count);
     }
 }
 public int GetWordCloud(string word)
 {
     using (var db = new MysqlDataContext())
     {
         var cmds = db.WrodCloudProc.FromSql("call wordranking({0})", word).Count();
         //var result = cmds.Count();
         return(cmds);
     }
 }
 public void AddHistory(History history)
 {
     using (var db = new MysqlDataContext())
     {
         history.HistoryId = db.History.Max(h => h.HistoryId) + 1;
         db.Add(history);
         db.SaveChanges();
     }
 }
 public IList <History> GetHistories(int page, int pageSize)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.History
                .Skip(page * pageSize)
                .Take(pageSize)
                .OrderBy(h => h.SearchDate).ToList());
     }
 }
 public IList <Comments> GetComments(int page, int pageSize)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.Comment
                .Skip(page * pageSize)
                .Take(pageSize)
                .OrderBy(c => c.CommentCeated).ToList());
     }
 }
 public int GetTotalSearchKeywordResult(string search)
 {
     using (var db = new MysqlDataContext())
     {
         var cmds = db.SearchKeyordStoredProc.FromSql("call search_keyword({0})", search);
         //var list = new List<SearchKeywordStoredProc>();
         var result = cmds.Count();
         return(result);
     }
 }
 public int GetTotalRankWord(string rankword)
 {
     using (var db = new MysqlDataContext())
     {
         var cmds = db.RankStoredProc.FromSql("call ranking({0})", rankword);
         //var list = new List<RankingStoredProc>();
         var result = cmds.Count();
         return(result);
     }
 }
 public IList <Tags> GetTags(int page, int pagesize)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.Tags
                .OrderBy(c => c.PostId)
                .Skip(page * pagesize)
                .Take(pagesize)
                .ToList());
     }
 }
 public IList <CombinedUsers> GetCombinedUsers(int page, int pagesize)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.CombineUsers
                .OrderBy(c => c.CombineUserId)
                .Skip(page * pagesize)
                .Take(pagesize)
                .ToList());
     }
 }
 public IList <Questions> GetQuestions(int page, int pageSize)
 {
     using (var db = new MysqlDataContext())
     {
         var questions = db.Question
                         .Skip(page * pageSize)
                         .Take(pageSize)
                         .ToList();
         return(questions);
     }
 }
 public IList <LinkPosts> GetLinkToPost(int page, int pageSize)
 {
     using (var db = new MysqlDataContext())
     {
         return(db.LinkPost
                .OrderBy(c => c.PostId)
                .Skip(page * pageSize)
                .Take(pageSize)
                .ToList());
     }
 }
        public IList <Posts> GetPosts(int page, int pageSize)
        {
            using (var db = new MysqlDataContext())
            {
                var post = db.Post
                           .Where(b => b.PostTypeId == 1)
                           .Skip(page * pageSize)
                           .Take(pageSize)
                           .OrderBy(p => p.creationDate)
                           .ToList();

                return(post);
            }
        }
        public IList <wordcloud> Getwordcloud(string word, int page, int pageSize)
        {
            using (var db = new MysqlDataContext())
            {
                var cmds   = db.WrodCloudProc.FromSql("call wordranking({0})", word);
                var result = new List <wordcloud>();

                foreach (var item in cmds)
                {
                    result.Add(item);
                }
                return(result);
            }
        }