Beispiel #1
0
        //
        // GET: /User/

        public ActionResult Index(string id)
        {
            var     client = new FacebookWebClient();
            dynamic me     = client.Get("me");

            ViewBag.Name = me.name;
            ViewBag.Id   = me.id.ToString();

            JokesFeedViewModel model = new JokesFeedViewModel();

            model.UserName = me.name;
            model.UserId   = me.id;

            dynamic jUser    = client.Get(id.ToString());
            string  userName = jUser.name;

            IJokesRepository jokeRep  = new JokesRepository();
            IVotesRepository votesRep = new VotesRepository();
            List <Jokes>     allJokes = jokeRep.GetJokesByUserId(int.Parse(id)).ToList <Jokes>();

            if (allJokes != null)
            {
                foreach (Jokes joke in allJokes)
                {
                    joke.UserVoteType   = votesRep.GetCurrentUserVote(joke.JokeId, joke.UserId);
                    joke.UpVotesCount   = votesRep.GetJokesVotesCount(joke.JokeId, true);
                    joke.DownVotesCount = votesRep.GetJokesVotesCount(joke.JokeId, false);
                    joke.UserName       = userName;
                }
                model.Jokes = allJokes;
            }
            ViewBag.Name = userName + "'s Page";
            return(View("PostsMain", model));
        }