Beispiel #1
0
        //
        // GET: /Main/

        public ActionResult MainPage()
        {
            user           currentUser = Session["user"] as user;
            WallPostsModel wpm         = new WallPostsModel();

            using (var entities = new ifollowdatabaseEntities4())
            {
                currentUser = entities.users.First(u => u.id == currentUser.id);
                wpm.BuildFromImagesAndPosts(currentUser.posts, currentUser.images);
            }

            return(View(wpm));
        }
        //
        // GET: /Main/

        public ActionResult MainPage()
        {
            user           currentUser = Session["user"] as user;
            WallPostsModel wpm         = new WallPostsModel();

            using (var entities = new ifollowdatabaseEntities4())
            {
                currentUser = entities.users.First(u => u.id == currentUser.id);

                ICollection <post>  posts     = currentUser.posts;
                ICollection <image> images    = currentUser.images;
                DbSet <follower>    followers = entities.followers;

                foreach (follower f in followers)
                {
                    if (f.followerId == currentUser.id)
                    {
                        using (var conn = new ifollowdatabaseEntities4())
                        {
                            user ff = conn.users.First(u => u.id == f.followedId);
                            foreach (image i in ff.images)
                            {
                                images.Add(i);
                            }

                            foreach (post p in ff.posts)
                            {
                                posts.Add(p);
                            }
                        }
                    }
                }

                wpm.BuildFromImagesAndPosts(currentUser.posts, currentUser.images);
            }

            return(View(wpm));
        }