public List <User_Post> GetAllFollowedPostByPostId(int postId) { List <User_Post> user_Posts = new List <User_Post>(); var followed_post_ids = db.Followed_Posts.Where(x => x.Main_Post_Id == postId).ToList().OrderByDescending(x => x.Order).Select(x => x.Followed_Post_Id).ToList(); foreach (var followed_post_id in followed_post_ids) { User_Post user_Post = db.All_Posts.Find(followed_post_id); user_Posts.Add(user_Post); } return(user_Posts); }
public List <User_Post> GetAllPostsByTag(int tag_id) { var allPostsIds = db.Tag_Of_Post.Where(x => x.TagId == tag_id).ToList().Select(x => x.Post_Id); List <User_Post> All_Post_ByTag_Id = new List <User_Post>(); foreach (var postId in allPostsIds) { User_Post post = db.All_Posts.Find(postId); All_Post_ByTag_Id.Add(post); } return(All_Post_ByTag_Id); }
public void Add_Post(User_Post post) { db.All_Posts.Add(post); db.SaveChanges(); }
// All access end points for database methods here.. public void Add_Post(User_Post post) { this.dataAccess.Add_Post(post); }