GetPostResponse() public static method

public static GetPostResponse ( string requestUri, FormData data ) : JResponse
requestUri string
data FormData
return JResponse
Esempio n. 1
0
        /// <summary>
        /// Signs in with user email and password and
        /// receives response from DoubanFM server.
        /// </summary>
        /// <param name="email">User email.</param>
        /// <param name="password">User password.</param>
        /// <param name="saveStatus">Indicates if this client should
        /// save user's status when sign-in succeeded.</param>
        /// <returns></returns>
        public LoginResponse Login(string email, string password,
                                   bool saveStatus)
        {
            //Get response via http post.
            var jResp = ConnectionManager.GetPostResponse(
                ConnectionManager.LoginUri,
                new LoginRequestForm(new LoginRequest(email, password)));

            //Create response from json.
            LoginResponse resp = new LoginResponse(jResp);

            if (resp.Result == LoginResult.Success)
            {
                //Update local storage for user status.
                StorageManager.ClearUserStatus();
                _status = new UserStatus()
                {
                    Expire = jResp.expire,
                    Token  = jResp.token,
                    UserID = jResp.user_id
                };

                if (saveStatus)
                {
                    StorageManager.SaveUserStatus(_status);
                }
            }

            return(resp);
        }
Esempio n. 2
0
        public LoginResponse GetResponse()
        {
            LoginRequestForm form = new LoginRequestForm(this);

            var jResp = ConnectionManager.GetPostResponse(
                ConnectionManager.LoginUri, form);

            return(new LoginResponse(jResp));
        }