Ejemplo n.º 1
0
        public ActionResult Post(string mediaID)
        {
            /* No current session could be found, back to the homepage. */
            if (this.Session["CurrentSession"] == null)
            {
                return(RedirectToAction("Index"));
            }

            /* Access the current InstagramSession and fetch all media. */
            InstagramSession      currentSession = (InstagramSession)this.Session["CurrentSession"];
            IList <InstagramPost> recentMedia    = currentSession.GetMedia();

            /* Search for the specific post mentioned in 'mediaID' */
            foreach (InstagramPost post in recentMedia)
            {
                /* Post has been found */
                if (post.ID == mediaID)
                {
                    /* Fetch the comments of post in discussion,
                     * create a ViewModel and return it. */
                    IList <InstagramComment> comments  = currentSession.GetComments(mediaID);
                    PostViewModel            viewModel = new PostViewModel {
                        Post = post, Comments = comments
                    };
                    return(View(viewModel));
                }
            }

            /* No media matching specified mediaID has been found */
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        // GET: Instagram/Media

        /* Returns latest media of currently authenticated user. The InstagramSession
         * object for the current session is preserved through .NET Session State.
         * */
        public ActionResult Media()
        {
            /* No current session could be found, back to the homepage. */
            if (this.Session["CurrentSession"] == null)
            {
                return(RedirectToAction("Index"));
            }

            /* Access the current InstagramSession and fetch user data/media. */
            InstagramSession      currentSession = (InstagramSession)this.Session["CurrentSession"];
            IList <InstagramPost> recentMedia    = currentSession.GetMedia();
            InstagramUser         currentUser    = currentSession.GetUser();

            /* Wrap the user and media into a single model and pass
             * that to the view for displaying purposes. */
            MediaViewModel viewModel = new MediaViewModel {
                User = currentUser, Media = recentMedia
            };

            return(View(viewModel));
        }