void HandleOnMatchUserCompleted(UserModel obj)
        {
            this.InvokeOnMainThread (
                delegate
            {
                busyIndicator.StopAnimating ();
                busyIndicator.Hidden = true;

                if (obj.IsSucess)
                {
                    try
                    {
                        m_lastMatchedUser = obj;
                        m_bottomCaption.Hidden = m_topCaption.Hidden = true;
                        m_placeHolderImageButton.Hidden = true;

                        //load ui elements with data;
                        m_matchedUsersName.Text = string.Format ("{0} {1}", m_lastMatchedUser.FirstName, m_lastMatchedUser.LastName);
                        m_matchedUsersInterest1.Text = m_lastMatchedUser.InterestOne;
                        m_matchedUsersInterest2.Text = m_lastMatchedUser.InterestTwo;
                        m_matchedUsersSummary.Text = m_lastMatchedUser.Summary;

                        m_matchedUsersImage.Hidden = false;
                        m_matchedUsersName.Hidden = false;
                        m_matchedUsersInterest1.Hidden = false;
                        m_matchedUsersInterest2.Hidden = false;
                        m_matchedUsersSummary.Hidden = false;
                    }
                    catch
                    {

                    }
                }
                else
                {

                    SayHiBootStrapper.ShowAlertMessage ("Error", "Could not find match. :(. Go Back and try again?");
                    NavigationController.PopViewControllerAnimated (true);

                }
            });
        }
Example #2
0
 public static void SetCurrentUser(UserModel user)
 {
     CurrentUser = user;
 }
        void HandleOnRegisterUserCompleted(UserModel obj)
        {
            if (!obj.IsSucess)
            {

                InvokeOnMainThread (
                    delegate
                {
                    SayHiBootStrapper.ShowAlertMessage ("Error", "Cannot register. Be sure that you did not already sign up for an account");
                });
            }
            else
            {
                SayHiBootStrapper.SetCurrentUser (obj);
                if (Mode == RegistrationMode.EventDetailDestination)
                {
                    if (CallingEventVC != null)
                    {
                        CallingEventVC.Mode = EventSummaryMode.CheckIn;
                    }
                    InvokeOnMainThread (delegate
                    {
                        NavigationController.PopViewControllerAnimated (true);
                    });
                    //take back to detail screen of event
                    //override prepare for segue so that i can show checkin button
                    //PerformSegue(SayHiConstants.)
                }
                else
                if (Mode == RegistrationMode.HomePageDestination)
                {
                    //take to home screen
                    InvokeOnMainThread (delegate
                    {
                        NavigationController.PopToRootViewController (true);
                    });
                }
            }
        }
Example #4
0
        public void RegisterUser(string username, string password, string firstName, string lastName, string emailAddress, string dob = "", 
		                         string summary = "awesome summery", string interest1 = "", string interest2 = "", string interest3 = "")
        {
            string json = ParamsToJSON ("dob", dob, "summary", summary, "user", SayHiHelper.JSONBeginObject, "email", emailAddress,
                                       "first_name", firstName, "last_name", lastName, "username", username, "password", password,
                                       SayHiHelper.JSONEndObject);
            SayHiRestClient syrc = new SayHiRestClient (SayHiRestClient.HTTPPOSTMETHOD, CreateEndpointURL (RegisterUserPath), json);
            syrc.OnRestCallCompleted += (RestResult obj) =>
            {
                UserModel ret = null;
                if (!obj.IsSuccess)
                {
                    ret = new UserModel (obj.IsSuccess, obj.Result);
                }
                else
                {
                    try
                    {
                        ret = new UserModel (true);

                        using (JsonTextReader jtr = new JsonTextReader(new StringReader(obj.Result)))
                        {

                            while (jtr.Read())
                            {
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "id"))
                                {
                                    ret.ID = jtr.ReadAsString ();
                                    break;//only parsing ID
                                }
                            }
                        }
                        //TODO:parse other fields

                        ret.FirstName = firstName;
                        ret.LastName = lastName;
                        ret.EmailAddress = emailAddress;
                        ret.DOBRaw = dob;
                        ret.Summary = summary;
                        ret.InterestOne = interest1;
                        ret.InterestTwo = interest2;
                        ret.InterestThree = interest3;
                    }
                    catch (Exception e)
                    {
                        ret = new UserModel (false, GenerateParseErrorMessage (e));
                    }
                }

                SafeRaiseEvent (OnRegisterUserCompleted, ret);
            };

            syrc.SendRestRequest ();
        }
Example #5
0
        public void MatchUser(string userId, string eventCode)
        {
            string json = ParamsToJSON ("userid", userId, "event_code", eventCode);

            SayHiRestClient syrc = new SayHiRestClient (SayHiRestClient.HTTPPOSTMETHOD, CreateEndpointURL (MatchUserPath), json);
            syrc.OnRestCallCompleted += (RestResult obj) =>
            {
                UserModel ret = null;

                if (!obj.IsSuccess)
                {
                    ret = new UserModel (obj.IsSuccess, obj.Result);
                }
                else
                {
                    try
                    {
                        ret = new UserModel (true);

                        using (JsonTextReader jtr = new JsonTextReader(new StringReader(obj.Result)))
                        {

                            while (jtr.Read())
                            {
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "matchName"))
                                {
                                    string name = jtr.ReadAsString ();
                                    if (name != null)
                                    {
                                        string[] vals = name.Split (' ');
                                        ret.FirstName = vals [0];
                                        if (vals.Length > 1)
                                        {
                                            ret.LastName = vals [1];
                                        }
                                    }
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "matchSummary"))
                                {
                                    ret.Summary = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "username"))
                                {
                                    ret.Summary = jtr.ReadAsString ();
                                }
                            }

                            ret.InterestOne = SayHiBootStrapper.GenerateMockInterest ();
                            ret.InterestTwo = SayHiBootStrapper.GenerateMockInterest (ret.InterestOne);
                        }
                    }
                    catch (Exception e)
                    {
                        ret = new UserModel (false, GenerateParseErrorMessage (e));
                    }
                }

                SafeRaiseEvent (OnMatchUserCompleted, ret);

            };
            syrc.SendRestRequest ();
        }
Example #6
0
        public void LoginUser(string username, string password)
        {
            string json = ParamsToJSON ("username", username, "password", password);
            SayHiRestClient syrc = new SayHiRestClient (SayHiRestClient.HTTPPOSTMETHOD, CreateEndpointURL (LoginUserPath), json);
            syrc.OnRestCallCompleted += (RestResult obj) =>
            {
                UserModel ret = null;

                if (!obj.IsSuccess)
                {
                    ret = new UserModel (obj.IsSuccess, obj.Result);
                }
                else
                {
                    try
                    {
                        ret = new UserModel (true);

                        using (JsonTextReader jtr = new JsonTextReader(new StringReader(obj.Result)))
                        {
            //							JsonIndexer idx = new JsonIndexer (jtr);
            //							ret.DOBRaw = idx ["dob"];
            //							ret.EmailAddress = idx ["email"];
            //							ret.ID = idx ["id"];
            //							ret.LastName = idx ["lastName"];
                            while (jtr.Read())
                            {
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "email"))
                                {
                                    ret.EmailAddress = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "firstName"))
                                {
                                    ret.FirstName = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "lastName"))
                                {
                                    ret.LastName = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "id"))
                                {
                                    ret.ID = jtr.ReadAsString ();
                                }

                            }

                            ret.InterestOne = SayHiBootStrapper.GenerateMockInterest ();
                            ret.InterestTwo = SayHiBootStrapper.GenerateMockInterest (ret.InterestOne ?? "");
                        }
                    }
                    catch (Exception e)
                    {
                        ret = new UserModel (false, GenerateParseErrorMessage (e));
                    }
                }

                SafeRaiseEvent (OnRegisterUserCompleted, ret);

            };
            syrc.SendRestRequest ();
        }