示例#1
0
        public IEnumerable <Post> GetAllPostForUser(int userid)
        {
            var context      = new SovaDbContext();
            var postForUsers = context.Posts.Where(x => x.UserId == userid);

            return(postForUsers);
        }
示例#2
0
 public int TotalPosts()
 {
     using (var db = new SovaDbContext())
     {
         return(db.Posts.Count());
     }
 }
示例#3
0
        public IEnumerable <User> GetUserById(int id)
        {
            var context  = new SovaDbContext();
            var userById = context.Users.Where(x => x.Id == id);

            return(userById);
        }
示例#4
0
        public IQueryable <Post> GetAllPost()
        {
            var context = new SovaDbContext();
            var posts   = context.Posts.Where(x => x.PosttypeId == 1).Include(x => x.User);

            return(posts);
        }
示例#5
0
        public IQueryable <User> GetAllUser()
        {
            var context = new SovaDbContext();
            var users   = context.Users;

            return(users);
        }
示例#6
0
 public IEnumerable <KeySearch> GetSearchResult(string searchTerm)
 {
     using (var db = new SovaDbContext())
     {
         return(db.KeySearch.FromSql("call keysearch({0})", searchTerm).ToList());
     }
 }
示例#7
0
        public IEnumerable <Post> GetPostById(int id)
        {
            var context = new SovaDbContext();
            var post    = context.Posts.Where(x => x.Id == id).Include(x => x.User)
                          .Include(x => x.Comments).ThenInclude(u => u.Users);

            return(post);
        }
示例#8
0
        public IQueryable <Post> GetAllAnswerForPost(int postid)
        {
            var context        = new SovaDbContext();
            var answersForPost = context.Posts.Where(x => x.PosttypeId == 2 && x.ParentId == postid)

                                 .Include(x => x.Comments);

            return(answersForPost);
        }
示例#9
0
        public IQueryable <Post> GetAllPost(Paging PageInfo)
        {
            var context = new SovaDbContext();
            var posts   = context.Posts.Where(x => x.PosttypeId == 1).Include(x => x.User)
                          .Skip((PageInfo.Page) * PageInfo.PageSize)
                          .Take(PageInfo.PageSize);

            return(posts);
        }
示例#10
0
 public UserServices(SovaDbContext dbContext)
 {
     this.context = dbContext;
 }
示例#11
0
 public CommentService(SovaDbContext dbContext)
 {
     this.DbContext = dbContext;
 }
示例#12
0
 public PostService(SovaDbContext context)
 {
     this.context = context;
 }