public void FacebookLogin()
 {
     fbWebContext = FacebookWebContext.Current; //get facebook session
     if (FacebookWebContext.Current.Session != null)
     {
         var app = new FacebookWebClient();
         var me = (IDictionary<string, object>)app.Get("me");   // get own information
         _FacebookUid = fbWebContext.UserId ;                // get own user id
         try
         {
             string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; // get first name and last name
             if (OnFacebookLogin(fbName))
             {
                 SaveSessionInDB();
                 return;
             }
             else
             {
                 string notice = string.Format("<h2>Welcome, {0}.</h2>" +
                     "<h3>Login here to connect your Facebook login to your account<br/>" +
                     "Or sign-up to create full account, connected with your Facebook credentials</h3>", fbName);
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
Beispiel #2
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);
        }
        public ActionResult RegisterLogOn(RegisterLogOnViewModel viewModel, string returnUrl)
        {
            if (FacebookWebContext.Current.IsAuthenticated())
            {
                var client = new FacebookWebClient();
                dynamic me = client.Get("me");

                if (!_userRepository.UserExist(me.username))
                {
                    var user = new User(AuthenticationType.Facebook) { Username = me.username };

                    _userRepository.Add(user);
                    _unitOfWork.Commit();
                }

                FormsAuthentication.SetAuthCookie((string)me.username, false);

                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    return Redirect(returnUrl);

                return RedirectToAction("Index", "Home");
            }

            return View("RegisterLogOn", viewModel);
        }
Beispiel #4
0
    public void BindData()
    {
        AppUser usr = ContextHelper.DataContext.User.First(o => o.UserId == SessionHelper.UserId);

        FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
        FacebookWebClient fb = new FacebookWebClient(wc);
        fb.AccessToken = usr.AccessToken;
        dynamic friends = fb.Get("/me/friends");

        List<string> userIds = new List<string>();
        foreach (dynamic friend in friends.data)
          userIds.Add(friend.id);

        if (userIds.Count() > 0)
        {
          DataTable dt = AppUserDao.GetUsersInfo(userIds);
          if (dt.Rows.Count > 0)
          {
        dlFriends.DataSource = dt;
        dlFriends.DataBind();
          }
          else
          {
        CommonFunctions.ShowInfo(lblStatus, "No friends found at timeflies");
          }
        }
        else
        {
          CommonFunctions.ShowInfo(lblStatus, "No friends found at timeflies");
        }
    }
Beispiel #5
0
        public ActionResult About()
        {
            var fb = new FacebookWebClient();
            dynamic result = fb.Get("me");
            ViewData["Firstname"] = (string)result.first_name;
            ViewData["Lastname"] = (string)result.last_name;

            return View();
        }
        public ActionResult Profile()
        {
            var client = new FacebookWebClient();

            dynamic me = client.Get("me");
            ViewBag.Name = me.name;
            ViewBag.Id = me.id;

            return View();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CanvasUrlBuilder = new CanvasUrlBuilder(FacebookApplication.Current, new HttpRequestWrapper(Request));

            var client = new FacebookWebClient();
            PicUrlWebClient = ((dynamic)client.Get("/4", new Dictionary<string, object> { { "fields", "picture" } })).picture;
            
            var app = new FacebookApp();
            PicUrlApp = ((dynamic)app.Get("/4", new Dictionary<string, object> { { "fields", "picture" } })).picture;
        }
Beispiel #8
0
        public ActionResult DataGrid()
        {
            var app = new FacebookWebClient();
            var fbContext = FacebookWebContext.Current;

            TennisUserModel existingUser = ModelUtils.GetTennisUsers(this.DB).Where(tu => tu.FacebookId == fbContext.UserId).FirstOrDefault();
            //ViewData.Model = new PlayersDataGridModel(existingUser, this.DB);

            return View("DataGrid");
        }
        public ActionResult MensagemPost(string message)
        {
            var fb = new FacebookWebClient();

            dynamic parameters = new ExpandoObject();
            parameters.message = message;

            dynamic result = fb.Post("me/feed", parameters);

            return RedirectToAction("Index", new { success = true });
        }
Beispiel #10
0
        public ActionResult Publish()
        {
            var app = new FacebookWebClient();

            dynamic parameters = new ExpandoObject();
            parameters.message = "First wall post!";

            dynamic result = app.Post("/me/feed", parameters);

            return RedirectToAction("About");
        }
Beispiel #11
0
        /// <summary>
        /// Check if the Facebook App has permissions from the specified user.
        /// </summary>
        /// <param name="context">
        /// The Facebook web context.
        /// </param>
        /// <param name="accessToken">
        /// The access token.
        /// </param>
        /// <param name="appId">
        /// The app id.
        /// </param>
        /// <param name="userId">
        /// The user id.
        /// </param>
        /// <param name="permissions">
        /// The list of permissions.
        /// </param>
        /// <returns>
        /// The list of permissions that are allowed from the specified permissions.
        /// </returns>
        internal static string[] HasPermissions(FacebookWebContext context, string accessToken, string appId, long userId, string[] permissions)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (string.IsNullOrEmpty(appId))
            {
                throw new ArgumentNullException("appId");
            }
            if (userId < 0)
            {
                throw new ArgumentOutOfRangeException("userId", "userId must be equal or greater than 0");
            }

            if (userId != 0 && !string.IsNullOrEmpty(accessToken))
            {
                try
                {
                    var fb = new FacebookWebClient(context)
                    {
                        AccessToken = accessToken
                    };
                    var remoteResult = ((IDictionary <string, object>)fb.Get("me/permissions"));
                    if (remoteResult != null && remoteResult.ContainsKey("data"))
                    {
                        var data = remoteResult["data"] as IList <object>;

                        if (data != null && data.Count > 0)
                        {
                            var permData = data[0] as IDictionary <string, object>;
                            if (permData == null)
                            {
                                return(new string[0]);
                            }
                            else
                            {
                                return((from perm in permData
                                        where perm.Value.ToString() == "1"
                                        select perm.Key).ToArray());
                            }
                        }
                    }
                }
                catch (FacebookOAuthException)
                {
                    return(null);
                }
            }

            return(null);
        }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckIfFacebookAppIsSetupCorrectly();

            var fbWebContext = FacebookWebContext.Current;
            if (fbWebContext.IsAuthorized())
            {
                var fb = new FacebookWebClient(fbWebContext);
                dynamic result = fb.Get("/me");

                lblMessage.Text = "Hi " + result.name;
            }
        }
Beispiel #13
0
        public ActionResult About()
        {
            var app = new FacebookWebClient();

            dynamic me = app.Get("me");
            dynamic friends = app.Get("/me/friends");

            dynamic model = new ExpandoObject();
            model.Name = me.name;
            model.FriendCount = friends.data.Count;

            return View(model);
        }
        //
        // GET: /FacebookLogin/
        public ActionResult Index()
        {
            if (FacebookWebContext.Current.IsAuthenticated())
            {
                var client = new FacebookWebClient();

                dynamic me = client.Get("me");
                ViewBag.Name = me.name;
                ViewBag.Id = me.id;
                ViewBag.Email = me.email;
            }
            return View();
        }
 /// <summary>
 /// List of friends is stored in result.data
 /// Name of friends in data.name
 /// Facebook id of friend in data.id
 /// </summary>
 public static JsonObject GetUserFriends()
 {
     try
     {
         var fb = new FacebookWebClient();
         return (JsonObject)fb.Get("/me/friends");
     }
     catch (Exception ex)
     {
         _logger.Error("Cannot get userFriends", ex);
         Debug.WriteLine(ex);
         return null;
     }
 }
 /// <summary>
 /// Get friend infos
 /// </summary>
 /// <param name="fid">Facebook Id of the requested user</param>
 /// <returns>A Json Array</returns>
 public static JsonObject GetFriendInfo(long fid)
 {
     try
     {
         var fb = new FacebookWebClient();
         return (JsonObject)fb.Get("/" + fid);
     }
     catch (Exception ex)
     {
         _logger.Error("Cannot get friendsInfo", ex);
         Debug.WriteLine(ex);
         return null;
     }
 }
Beispiel #17
0
    private void ShowFacebookContent()
    {
        var fb = new FacebookWebClient();
        dynamic myInfo = fb.Get("me");
        lblName.Text = myInfo.name;
        pnlHello.Visible = true;

        /* OR */

        //var fbApp = new FacebookApp();
        //dynamic info = fbApp.Get("me");
        //lblName.Text = info.name;
        //pnlHello.Visible = true;
    }
 /// <summary>
 /// Get friend's name from its fid
 /// </summary>
 /// <param name="fid">Friend's fid</param>
 public static string GetFriendName(long fid)
 {
     try
     {
         var fb = new FacebookWebClient();
         dynamic result = fb.Get("/" + fid);
         return (result.last_name + " " + result.first_name);
     }
     catch (Exception ex)
     {
         _logger.Error("Cannot get friendsName", ex);
         Debug.WriteLine(ex);
         return null;
     }
 }
 /// <summary>
 /// Get friend infos
 /// </summary>
 /// <param name="fid">Facebook Id of the requested user</param>
 /// <returns>A Json Array</returns>
 public static dynamic GetFriendInfo(long fid)
 {
     try
     {
         var fb = new FacebookWebClient();
         dynamic result = fb.Get("/" + fid);
         return result;
     }
     catch (Exception ex)
     {
         _logger.Error("Cannot get friendsInfo", ex);
         Debug.WriteLine(ex);
         return null;
     }
 }
        public ActionResult Index()
        {
            var fb = new FacebookWebClient();
            dynamic me = fb.Get("me");

            ViewBag.ProfilePictureUrl = string.Format("http://graph.facebok.com/{0}/picture", me.id);
            ViewBag.Name = me.name;
            ViewBag.FirstName = me.first_name;
            ViewBag.LastName = me.last_name;

            ViewBag.MessagePostSuccess = Request.QueryString.AllKeys.Contains("success") &&
                                            Request.QueryString["success"] == "True";

            return View();
        }
 /// <summary>
 /// Get friend's name from its fid
 /// </summary>
 /// <param name="fid">Friend's fid</param>
 public static string GetFriendName(long fid)
 {
     try
     {
         var fb = new FacebookWebClient();
         var result = (JsonObject)fb.Get("/" + fid);
         return (result["last_name"] + " " + result["first_name"]);
     }
     catch (Exception ex)
     {
         _logger.Error("Cannot get friendsName", ex);
         Debug.WriteLine(ex);
         return null;
     }
 }
Beispiel #22
0
    public bool IsFbFriend(string videoUserId, string friendUserId)
    {
        AppUser usr = ContextHelper.DataContext.User.First(o => o.UserId == videoUserId);

        FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
        FacebookWebClient fb = new FacebookWebClient(wc);
        fb.AccessToken = usr.AccessToken;
        dynamic friends = fb.Get("/me/friends");

        List<string> userIds = new List<string>();
        foreach (dynamic friend in friends.data)
          userIds.Add(friend.id);

        return userIds.Contains(friendUserId);
    }
        public ActionResult Profile()
        {
            if (FacebookWebContext.Current.IsAuthenticated())
            {
                var client = new FacebookWebClient();

                dynamic me = client.Get("me");
                ViewBag.Friends = me;
                ViewBag.ShouldConnect = false;
            }
            else
            {
                ViewBag.ShouldConnect = true;
            }
            return View();
        }
Beispiel #24
0
        private static List<Images> GetFriendImages(string userToken, TimeFliesByEntities dc)
        {
            FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
              FacebookWebClient fb = new FacebookWebClient(wc);
              fb.AccessToken = userToken;
              dynamic friends = fb.Get("/me/friends");

              List<Images> images = new List<Images>();
              foreach (dynamic friend in friends.data)
              {
            string friendId = friend.id;
            Images image = dc.Images.Where(o => o.UserId == friendId).OrderByDescending(o => o.ImageId).FirstOrDefault();
            if (image != null)
              images.Add(image);
              }
              return images.OrderByDescending(o => o.DateAdded).Take(5).ToList();
        }
        /// <summary>
        /// Check if the Facebook App has permissions from the specified user.
        /// </summary>
        /// <param name="appId">
        /// The app id.
        /// </param>
        /// <param name="appSecret">
        /// The app secret.
        /// </param>
        /// <param name="userId">
        /// The user id.
        /// </param>
        /// <param name="permissions">
        /// The list of permissions.
        /// </param>
        /// <returns>
        /// The list of permissions that are allowed from the specified permissions.
        /// </returns>
        internal static string[] HasPermissions(string appId, string appSecret, long userId, string[] permissions)
        {
            Contract.Requires(!string.IsNullOrEmpty(appId));
            Contract.Requires(!string.IsNullOrEmpty(appSecret));
            Contract.Requires(permissions != null);
            Contract.Requires(userId >= 0);
            Contract.Ensures(Contract.Result <string[]>() != null);

            var result = new string[0];

            if (userId != 0)
            {
                var perms = new StringBuilder();
                for (int i = 0; i < permissions.Length; i++)
                {
                    perms.Append(permissions[i]);
                    if (i < permissions.Length - 1)
                    {
                        perms.Append(",");
                    }
                }

                var query      = string.Format(CultureInfo.InvariantCulture, "SELECT {0} FROM permissions WHERE uid == {1}", perms, userId);
                var parameters = new Dictionary <string, object>();
                parameters["query"]  = query;
                parameters["method"] = "fql.query";

                var fb   = new FacebookWebClient(appId, appSecret);
                var data = fb.Get(parameters) as IList <object>;

                if (data != null && data.Count > 0)
                {
                    var permData = data[0] as IDictionary <string, object>;
                    if (permData != null)
                    {
                        result = (from perm in permData
                                  where perm.Value.ToString() == "1"
                                  select perm.Key).ToArray();
                    }
                }
            }

            return(result);
        }
Beispiel #26
0
        private void ShowFacebookContent()
        {
            var fb = new FacebookWebClient();
            dynamic myInfo = fb.Get("me");
            lblName.Text = myInfo.name;
            pnlHello.Visible = true;

            dynamic myFriendsInfo = fb.Get("me/friends");
            foreach (var friend in myFriendsInfo.data)
            {
                FriendsList.Items.Add(friend.name);
            }
            /* OR */

            //var fbApp = new FacebookApp();
            //dynamic info = fbApp.Get("me");
            //lblName.Text = info.name;
            //pnlHello.Visible = true;
        }
Beispiel #27
0
        public string AuthenticateUser(string userId, string token)
        {
            try
              {
            using (TimeFliesByEntities dc = new TimeFliesByEntities(Settings.EFConnectionString))
            {
              string videoId = "id_";
              if (dc.User.Count(o => o.UserId == userId) > 0)
              {
            videoId += dc.Videos.First(o => o.UserId == userId).VideoId;
              }
              else // Add New User
              {
            FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
            FacebookWebClient fb = new FacebookWebClient(wc);
            fb.AccessToken = token;
            dynamic result = fb.Get("/me");
            string fbEmail = result.email ?? String.Empty;
            userId = result.id;
            videoId += RegisterUser(result.id, result.email, result.first_name + " " + result.last_name, token);

            /*
            const string username = "******";
            Person userData = FacebookSvc.GetUserData(token, username);
            string FQLquery = "https://api.facebook.com/method/fql.query?query=select%20email%20from%20user%20where%20uid%3D" + userData.id + "&access_token=" + token + "";
            string resp = new oAuthFacebook().WebRequest(oAuthFacebook.Method.GET, FQLquery, string.Empty);
            DataSet ds = new DataSet();
            StringReader xmlReader = new StringReader(resp);
            ds.ReadXml(xmlReader);
            string email = ds.Tables[1].Rows[0][0].ToString();
            videoId += RegisterUser(userData.id, email, userData.first_name + " " + userData.last_name, token);
             */
              }
              return videoId;
            }
              }
              catch (Exception ex)
              {
            EmailService.ErrorEmail(ex);
            return ex.Message;
              }
        }
        public ActionResult Index()
        {
            var fb = new FacebookWebClient();
            dynamic me = fb.Get("me");

            ViewBag.id = me.id;
            ViewBag.name = me.name;
            ViewBag.firstname = me.first_name;

            FriendLikesService service = new FriendLikesService(me.id, fb.AccessToken);

            ViewBag.webUrl = RoleEnvironment.GetConfigurationSettingValue("WebURL");
            ViewBag.blobUrl = RoleEnvironment.GetConfigurationSettingValue("BlobURL");

            if (service.isCached())
            {
                //// The data is cached, we can retrieve it and use it server-side...
                //// The ViewBag is used by the default Index view
                //service.GetFriendsLikes();
                //ViewBag.friendLikes = service.GetOrderedFriendLikes();
                //var cats = service.GetCategories().OrderByDescending(k => k.Value).ToList();
                //var max = cats.Max(k => k.Value);
                //var min = cats.Min(k => k.Value);
                //ViewBag.categories = cats;
                //ViewBag.max = max;
                //ViewBag.min = min;

                // Return the IndexJS view to use the cached data on the client
                return View("IndexJS");
            }
            else
            {
                // Need to send this to the Worker Role
                service.QueueLike();
                return View("PleaseWait");
            }

            return View();
        }
Beispiel #29
0
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";
            ViewBag.fb_loggedIn = false;

            if (FacebookWebContext.Current != null) {
                if (FacebookWebContext.Current.IsAuthenticated())
                {
                    var client = new FacebookWebClient();
                    dynamic me = client.Get("me");

                    ViewBag.fb_loggedIn = true;
                    ViewBag.FirstName = me.first_name;
                    ViewBag.LastName = me.last_name;
                    ViewBag.Id = me.id;
                    ViewBag.Picture = me.picture;
                    ViewBag.Email = me.email;

                }
            }

            return View();
        }
    public void FacebookLogin()
    {
        fbwebContext = FacebookWebContext.Current;
        if (FacebookWebContext.Current.Session != null)
        {
            _FacebookUid = fbwebContext.UserId;
            try
            {
                var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken);
                var me = (IDictionary<string, object>)fbwc.Get("me");
                string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; // get first name and last name
                if (OnFacebookLogin(fbName))
                {
                    SaveSessionInDB();
                    return;
                }
                else
                {
                    string notice = string.Format("<h2>Welcome, {0}.</h2>" +
                        "<h3>Login here to connect your Facebook login to your account<br/>" +
                        "Or sign-up to create full account, connected with your Facebook credentials</h3>", fbName);
                    if (Request.QueryString["ytfblink"] != null)
                    {

                    }
                    else
                    {

                    }
                }
            }
            catch (FacebookOAuthException ex)
            {

            }
        }
    }
    private void SetPanelsVisibility(bool val)
    {
        if (ConfigurationManager.AppSettings["ApplicationType"].ToLower() == "yourtribute")
         {
             PanelUserName.Visible = val;
             UpdatePanel1.Visible = val;
             CityPanel.Visible = val;

             if (val == false)
             {
                 PanelPassword.Attributes.Remove("class");
                 PanelPassword.CssClass = "yt-signup-Password";
                 PanelConfirmPassword.CssClass = "yt-signup-ConfirmPassword";
                 SignupNewsLetter.InnerHtml = "I would like to receive periodic newsletters from Your Tribute, including company news and special offers.";
             }
             else
             {
                 PanelPassword.CssClass = "signup-Password";
                 PanelConfirmPassword.CssClass = "signup-Password";
                 SignupNewsLetter.InnerHtml = "I would like to receive periodic newsletters, including tips and tricks when creating tributes,from Your Tribute.";
             }
         }
        else
        {
            SignupNewsLetter.InnerHtml = "I would like to receive periodic newsletters, including tips and tricks when creating websites,from Your Moments.";
        }

        txtEmail.Focus();
        lblBusinessAcctDesc.Visible = val;
        BusinessTypePanel.Visible = val;
        WebsitePanel.Visible = val;
        StreetAddressPanel.Visible = val;
        CompanyNamePanel.Visible = val;
        ZipCodePanel.Visible = val;
        PanelPhone.Visible = val;
        FirstNamePanel.Visible = !val;
        LastNamePanel.Visible = !val;
        lblPersonalAcctDesc.Visible = !val;
        txtWebsiteAddress.Text = "";
        txtEmail.Text = "";

        // Added For Event Handling - Parul
        if (Request.QueryString["EventID"] != null)
        {
            string email = Request.QueryString["Email"];

            txtEmail.Text = email;
        }
        else if (Request.QueryString["TributeID"] != null)
        {
            if (Request.QueryString["Email"] != null)
                txtEmail.Text = Request.QueryString["Email"];
        }

        txtUsername.Text = "";
        txtPassword.Text = "";
        txtConfirmPassword.Text = "";
        txtBusinessName.Text = "";
        txtFirstName.Text = "";
        txtLastName.Text = "";
        txtStreetAddress.Text = "";
        txtCity.Text = "";
        txtPhoneNumber1.Text = "";
        txtPhoneNumber2.Text = "";
        txtPhoneNumber3.Text = "";
        txtZipCode.Text = "";
        rfvtxtCity.Visible = val;
        ddlBusinessType.SelectedIndex = 0;
        ddlCountry.SelectedIndex = 0;
        this._presenter.OnStateLoad(Locationid(ddlCountry.SelectedValue));
        chkAgreeTermsUse.Checked = false;

        if (FacebookWebContext.Current.Session != null)
        {
            //Display user data captured from the Facebook API.
            try
            {
                var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken);
                var me = (IDictionary<string, object>)fbwc.Get("me");
                string fql = "Select current_location, email from user where uid = " + (string)me["id"];
                JsonArray me2 = (JsonArray)fbwc.Query(fql);
                var mm = (IDictionary<string, object>)me2[0];

                txtFirstName.Text = (string)me["first_name"];
                txtLastName.Text = (string)me["last_name"];

                JsonObject hl = (JsonObject)mm["current_location"];

                if ((string)hl[0] != null)
                {
                    txtCity.Text = (string)hl[0];
                    setLocationFromFacebookLocation(ddlCountry, (string)hl[2]);
                    this._presenter.OnStateLoad(Locationid(ddlCountry.SelectedValue));
                    setLocationFromFacebookLocation(ddlStateProvince, (string)hl[1]);
                }

                string email_ = string.Empty; // user.proxied_email;
                string result = (string)mm["email"];
                if (!string.IsNullOrEmpty(result))
                {
                     email_ = result;
                }
                txtEmail.Text = email_;
            }
            catch (Exception ex)
            {
                if (!PortalValidationSummary.Visible)
                {
                    string msg =
                        "Problems with Facebook session. Please <a href=\"#\" onclick=\"fb_logout(); return false;\">" +
                        "   <img id=\"fb_logout_image\" src=\"http://static.ak.fbcdn.net/images/fbconnect/logout-buttons/logout_small.gif\" alt=\"Connect\"/>" +
                        "</a> and try again." + ex;
                    lblErrMsg.InnerHtml = ShowMessage(headertext, msg, 0);
                    lblErrMsg.Visible = true;
                }
            }
        }
    }
    private UserRegistration SaveAccount()
    {
        int usertype = 1;
        if (rdoBusinessAccount.Checked)
            usertype = 2;

        UserRegistration objUserReg = new UserRegistration();
        int state = -1;
        if (ddlStateProvince.SelectedValue != "")
        {
            state = int.Parse(ddlStateProvince.SelectedValue);
        }
        string _Pass = TributePortalSecurity.Security.EncryptSymmetric(txtPassword.Text.ToLower());
        string _UserImage = "images/bg_ProfilePhoto.gif";
        Nullable<Int64> facebookUid = null;

        var fbWebContext = FacebookWebContext.Current;
        if (FacebookWebContext.Current.Session != null)
            {
                facebookUid = fbWebContext.UserId;
                try
                {
                    var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken);
                    string fql = "Select pic_square from user where uid = " + fbWebContext.UserId;
                    JsonArray me2 = (JsonArray)fbwc.Query(fql);

                    var mm = (IDictionary<string, object>)me2[0];
                    if (!string.IsNullOrEmpty((string)mm["pic_square"]))
                {
                    _UserImage = (string)mm["pic_square"]; // get user image
                }
            }
            catch //(Exception ex) // commented by Ud to remove warning
            {
            }
        }

        Users objUsers = new Users(
                                    txtUsername.Text.Trim(),
                                    _Pass,
                                    txtFirstName.Text,
                                    txtLastName.Text,
                                    txtEmail.Text,
                                    "",
                                    chkAgreeReceiveNewsletters.Checked,
                                    txtCity.Text,
                                    state,
                                    int.Parse(ddlCountry.SelectedValue),
                                    usertype,facebookUid,ApplicationType
                                      );
        objUsers.UserImage = _UserImage;
        UserBusiness objUserBus = new UserBusiness();
        //Check for Personal Account.

        //Check for Business Account.
        if (rdoBusinessAccount.Checked)
        {
            objUserBus.Website = txtWebsiteAddress.Text;
            objUserBus.CompanyName = txtBusinessName.Text;
            objUserBus.BusinessType = int.Parse(ddlBusinessType.SelectedValue);
            objUserBus.BusinessAddress = txtStreetAddress.Text;
            objUserBus.ZipCode = txtZipCode.Text;

            objUserBus.Phone = txtPhoneNumber1.Text + txtPhoneNumber2.Text + txtPhoneNumber3.Text;

            objUserReg.UserBusiness = objUserBus;
        }
        objUserReg.Users = objUsers;
        return objUserReg;
    }