public ActionResult GetData(int id)
        {
            if (!ModelState.IsValid)
            {
                return(HttpNotFound());
            }


            var url = _context.Facebooks.Where(fb => fb.Id == id).Select(fb => fb.Url).SingleOrDefault();

            if (String.IsNullOrWhiteSpace(url))
            {
                return(HttpNotFound());
            }

            try
            {
                FacebookGraph fbGraph       = new FacebookGraph(url);
                string        numberOfLikes = fbGraph.getNumberOfLikes();
                if (String.IsNullOrWhiteSpace(numberOfLikes))
                {
                    ViewBag.text = "Please skip this page";
                    return(PartialView("Message"));
                }

                TempData["numberOfLikes"] = numberOfLikes;
                return(Redirect(url));
            }
            catch (Exception)
            {
                ViewBag.text = "This page is broken. Please skip it.";
                return(PartialView("Message"));
            }
        }
        public ActionResult GetLikesAfter(int id)
        {
            if (!ModelState.IsValid && !Request.IsAjaxRequest())
            {
                return(RedirectToAction("Index"));
            }

            var facebookPage = _context.Facebooks.Where(fb => fb.Id == id).SingleOrDefault();

            if (facebookPage == null)
            {
                return(HttpNotFound());
            }

            FacebookGraph fbGraph       = new FacebookGraph(facebookPage.Url);
            var           numberOfLikes = fbGraph.getNumberOfLikes();

            if (numberOfLikes == null)
            {
                ViewBag.text = "Broken Page. Please skip";
                return(PartialView("Message"));
            }

            if (Convert.ToInt32(numberOfLikes) > Convert.ToInt32(TempData["numberOfLikes"]))
            {
                var idUser       = User.Identity.GetUserId();
                var userWhoLiked = _context.Users.Where(u => u.Id == idUser).Single();

                if (userWhoLiked != null)
                {
                    userWhoLiked.Points         = userWhoLiked.Points + facebookPage.Cpc - 1;
                    facebookPage.User.Points    = facebookPage.User.Points - facebookPage.Cpc;
                    facebookPage.NumberOfClicks = facebookPage.NumberOfClicks + 1;
                    userWhoLiked.ClicksToday   += 1;
                    var facebookLike = new FacebookLiked()
                    {
                        FacebookPageId = facebookPage.Id, UserId = userWhoLiked.Id
                    };
                    _context.FacebookLikes.Add(facebookLike);
                    _context.SaveChanges();
                    ViewBag.text   = "You succesfully like " + facebookPage.Name;
                    ViewBag.points = userWhoLiked.Points;
                    ViewBag.pageid = facebookPage.Id;
                }
                return(PartialView("_TextConfirmation", facebookPage));
            }
            else
            {
                TempData["numberOfLikes"] = "9999999";
                ViewBag.text = "You didn't like this page.";
                return(PartialView("Message"));
            }
        }