Ejemplo n.º 1
0
        public ActionResult Index(long? replyTo)
        {
            if (Token == null)
            {
                ViewData["Url"] = new AuthenticationService().GetAuthenticationUrl();
                return View("Unauthenticated");
            }

            var service = new StatusesService(Token);

            ViewData["Action"] = "Index";
            ViewData["PageTitle"] = "home";

            if (replyTo != null)
            {
                try
                {
                    ViewData["InReplyTo"] = service.GetSingleStatus(replyTo.Value);
                }
                catch (TweetSharpException ex)
                {
                    //todo - I can't find a good way to detect invalid tweet IDs other than catching the error when thrown.  
                    //So, we try/catch, signal the error and redirect home without the replyTo.
                    ErrorSignal.FromCurrentContext().Raise(ex, System.Web.HttpContext.Current);
                    return RedirectToAction("Index");
                }
            }

            //if this call fails it will fail in the view and be handled by our standard error handing mechanism
            ViewData["loadInitialData"] =
                ExecuteOrRedirect(() => new JavaScriptSerializer().Serialize(service.OnHomeTimeline(null, null)));

            ViewData["loadMoreUrl"] = "/statuses/onHomeTimeline/";

            return View();
        }