public LoginResult Login(LoginModel loginModel) { var url = string.Format("{0}/api/Account/Authenticate", _baseUrl); var client = new RestClient(); var body = new JsonBodyContent(JsonConvert.SerializeObject(new { loginModel.Email, loginModel.Password })); try { var response = client.Post(url, body); var loginResult = JsonConvert.DeserializeObject <LoginResult>(response.Body); loginResult.StatusCode = response.StatusCode; return(loginResult); } catch (UnexpectedStatusException ex) { return(new LoginResult((HttpStatusCode)ex.StatusCode)); } }
public RegisterResult Register(TestUser user) { var url = string.Format("{0}/api/Account/Register", _baseUrl); var client = new RestClient(); var body = new JsonBodyContent(JsonConvert.SerializeObject(new { user.Email, user.Password })); try { var response = client.Post(url, body); var registerResult = JsonConvert.DeserializeObject <RegisterResult>(response.Body); registerResult.StatusCode = response.StatusCode; return(registerResult); } catch (UnexpectedStatusException ex) { return(new RegisterResult((HttpStatusCode)ex.StatusCode)); } }