public IEnumerable <Post> GetAllPostForUser(int userid) { var context = new SovaDbContext(); var postForUsers = context.Posts.Where(x => x.UserId == userid); return(postForUsers); }
public int TotalPosts() { using (var db = new SovaDbContext()) { return(db.Posts.Count()); } }
public IEnumerable <User> GetUserById(int id) { var context = new SovaDbContext(); var userById = context.Users.Where(x => x.Id == id); return(userById); }
public IQueryable <Post> GetAllPost() { var context = new SovaDbContext(); var posts = context.Posts.Where(x => x.PosttypeId == 1).Include(x => x.User); return(posts); }
public IQueryable <User> GetAllUser() { var context = new SovaDbContext(); var users = context.Users; return(users); }
public IEnumerable <KeySearch> GetSearchResult(string searchTerm) { using (var db = new SovaDbContext()) { return(db.KeySearch.FromSql("call keysearch({0})", searchTerm).ToList()); } }
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); }
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); }
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); }
public UserServices(SovaDbContext dbContext) { this.context = dbContext; }
public CommentService(SovaDbContext dbContext) { this.DbContext = dbContext; }
public PostService(SovaDbContext context) { this.context = context; }