// // GET: /Account/ public ActionResult Index() { if (Session["LoggedASP"] != null) { ViewData["username"] = ((User)Session["LoggedUser"]).Username; if (!String.IsNullOrEmpty(Request.QueryString["oauth_token"])) { OAuthTokenResponse tokens = OAuthUtility.GetAccessTokenDuringCallback(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"]); UserEntity entity = new UserEntity(); entity.EditUser(((User)Session["LoggedUser"]).ID, tokens.Token, tokens.TokenSecret, tokens.UserId.ToString(), tokens.ScreenName); Session["LoggedUser"] = entity.GetUserFromUsername(((User)Session["LoggedUser"]).Username); Session["LoggedTwitter"] = true; ViewData["TwitterUsername"] = TwitterUser.Show(Decimal.Parse(((User)Session["LoggedUser"]).TwitterID)).ResponseObject.ScreenName; //Session["accessToken"] = myToken; //ViewData["Logged"] = true; } else if (Session["LoggedTwitter"] != null) { OAuthTokens token = new OAuthTokens(); token.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"]; token.ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"]; token.AccessToken = ((User)Session["LoggedUser"]).TwitterToken; token.AccessTokenSecret = ((User)Session["LoggedUser"]).TwitterTokenSecret; /*ViewData["TwitterUsername"] = TwitterUser.Show(token,Decimal.Parse(((User)Session["LoggedUser"]).TwitterID)).ResponseObject.ScreenName;*/ } return(View()); } else { return(Redirect("http://" + Request.Url.Authority.ToString())); } }