Exemplo n.º 1
0
 public int GetNumberOfUsers()
 {
     using (var context = new StackOverflowContext())
     {
         return(context.User.Count());
     }
 }
Exemplo n.º 2
0
        /*
         * public int GetNumberOfTagPosts()
         * {
         *  using (var context = new StackOverflowContext())
         *  {
         *      return context.TagPost.Count();
         *  }
         * } */

        public int GetNumberOfMarkedPost()
        {
            using (var context = new StackOverflowContext())
            {
                return(context.MarkedPost.Count());
            }
        }
Exemplo n.º 3
0
 /*
  *
  * User related functions
  *
  */
 public User GetUser(int id)
 {
     using (var context = new StackOverflowContext())
     {
         return(context.User.Find(id));
     }
 }
Exemplo n.º 4
0
 public List <WordTf> GetTFsOfWord(int wordId)
 {
     using (var db = new StackOverflowContext())
     {
         return(db.WordTfs.Where(w => w.WordId == wordId).ToList());
     }
 }
Exemplo n.º 5
0
        /*
         * public IList<Post> GetPostsByTag(int pageNumber, int pageSize)
         * {
         *  using (var context = new StackOverflowContext())
         *  {
         *      return context.Post.Skip((pageNumber
         *       - 1) * pageSize).Take(pageSize).Where(context.Post.).ToList();
         *  }
         * }*/

        /*
         * public IList<TagPost> GetPostsByTag(int pageNumber, int pageSize)
         * {
         *  using (var context = new StackOverflowContext())
         *  {
         *      return context.TagPost
         *          //.OrderBy(x => x.Name)
         *          .Skip((pageNumber - 1) * pageSize)  //
         *          .Take(pageSize) // limit in db
         *          .ToList();
         *  }
         * }   */
        public int GetNumberOfComment()
        {
            using (var context = new StackOverflowContext())
            {
                return(context.Comment.Count());
            }
        }
Exemplo n.º 6
0
 public Tag GetTag(int id)
 {
     using (var context = new StackOverflowContext())
     {
         return(context.Tag.Find(id));
     }
 }
Exemplo n.º 7
0
 public Post GetPost(int id)
 {
     using (var context = new StackOverflowContext())
     {
         return(context.Post.Find(id));
     }
 }
Exemplo n.º 8
0
        /*
         * public TagPost GetTagOfPost(int id)
         * {
         *  using (var context = new StackOverflowContext())
         *  {
         *      return context.TagPost.Find(id);
         *  }
         * }*/

        public Comment GetComment(int id)
        {
            using (var context = new StackOverflowContext())
            {
                return(context.Comment.Find(id));
            }
        }
Exemplo n.º 9
0
 public int GetNumberOfHisotry()
 {
     using (var context = new StackOverflowContext())
     {
         return(context.History.Count());
     }
 }
Exemplo n.º 10
0
 public WordIdf GetIDFOfWord(string word)
 {
     using (var db = new StackOverflowContext())
     {
         return(db.WordIdfs.Where(w => w.Word == word).First());
     }
 }
Exemplo n.º 11
0
 public History GetHistory(int id)
 {
     using (var context = new StackOverflowContext())
     {
         return(context.History.Find(id));
     }
 }
Exemplo n.º 12
0
 public void DeleteMarkedPost(MarkedPost post)
 {
     using (var contex = new StackOverflowContext())
     {
         contex.MarkedPost.Remove(post);
         contex.SaveChanges();
     }
 }
Exemplo n.º 13
0
 public void DeleteHistory(History hist)
 {
     using (var contex = new StackOverflowContext())
     {
         contex.History.Remove(hist);
         contex.SaveChanges();
     }
 }
Exemplo n.º 14
0
 public IList <Post> GetPosts(int pageNumber, int pageSize)
 {
     using (var context = new StackOverflowContext())
     {
         return(context.Post
                //.OrderBy(x => x.Name)
                .Skip((pageNumber - 1) * pageSize) //
                .Take(pageSize)                    // limit in db
                .ToList());
     }
 }
Exemplo n.º 15
0
 public IList <Tag> GetTags(int pageNumber, int pageSize)
 {
     using (var context = new StackOverflowContext())
     {
         return(context.Tag
                .OrderByDescending(x => x.PostCount)
                .Skip((pageNumber - 1) * pageSize) //
                .Take(pageSize)                    // limit in db
                .ToList());
     }
 }
Exemplo n.º 16
0
        public void CreateMarkedPost(MarkedPost post)
        {
            using (var contex = new StackOverflowContext())
            {
                contex.MarkedPost.Add(post);
                contex.SaveChanges();
                //var nextId = contex.Categories.Max(x => x.Id) + 1;
                //category.Id = nextId;
                // Instead of this change the database to use auto increment on
                // the categoryid in the category table.
                // Note: that you need to remove the foreign key in product first,
                // then add the AI and finally reenter the FK on product.

                //contex.Categories.Add(category);
                //contex.SaveChanges();
            }
        }