Example #1
0
        public void FacebookLogin(string code)
        {
            UserDetails facebookUser = GetFacebookUserData(code);
            UserDetails user         = new UserDetails();

            // Check the existance of an identical local account
            PickrWebService api    = new PickrWebService();
            JObject         json   = api.CheckUserExistence(facebookUser.Email);
            bool            exists = (bool)json["Value"];

            if (exists)
            {
                json = api.GetUser(facebookUser.Email);
                JSONParser parser = new JSONParser();
                user = parser.ParseUser(json);

                // Update profile with facebook data
                json = api.UpdateUser(user.Email, facebookUser.FirstName, facebookUser.Surname, DateTime.MinValue, "", "", facebookUser.Picture, "", "", "");
                bool updated = parser.ParseUpdateTable(json);
                //UpdateUser(user.Email, facebookUser.FirstName, facebookUser.Surname, DateTime.MinValue, "", "", facebookUser.Picture, "", "");

                LocalLogin(user.Email, user.Password);
            }

            else
            {
                HttpContext.Current.Session["FacebookUser"] = facebookUser;
                Response.Redirect("/Account/RegisterFacebook");
            }
        }
Example #2
0
        public bool UpdateProfile(string firstname, string surname, DateTime birth, string gender, string mobile, string picture, string address, string mode, string car, bool?smoking, bool?music, bool?pets, int?talking)
        {
            PickrWebService api    = new PickrWebService();
            JSONParser      parser = new JSONParser();
            UserDetails     u      = (UserDetails)HttpContext.Current.Session["User"];

            JObject json = api.UpdateUser(u.Email, firstname, surname, birth, gender, mobile, picture, address, mode, car);


            bool updated = false;

            updated = parser.ParseUpdateTable(json);


            if (smoking != null && music != null && pets != null && talking != null)
            {
                JObject jsonPrefs    = api.SetUserPreferences(u.Email, (bool)smoking, (bool)music, (bool)pets, (int)talking);
                bool    prefsUpdated = false;
                prefsUpdated = parser.ParseUpdateTable(jsonPrefs);
                updated      = updated && prefsUpdated;
            }



            if (updated)
            {
                json = api.GetUser(u.Email);
                u    = parser.ParseUser(json);

                // Update session user
                HttpContext.Current.Session["User"] = u;
                Response.Redirect("Manage?updated=true");
            }

            else if (!updated)
            {
                ErrorMessage.Text = "Profile could not be updated.";
            }

            return(updated);
        }