public async Task <HttpResponseMessage> Login() { HttpResponseMessage response = null; FormUrlEncodedContent postParams = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("UserName", user.username), new KeyValuePair <string, string>("Password", user.password) }); response = await client.MakePost(postParams, loginUrl); if (response == null) { PostFailed error = new PostFailed(response, "Post response null"); throw error; } else if (response.RequestMessage.RequestUri.ToString().IndexOf(loginUrl) != -1) { LoginPostFailed error = new LoginPostFailed(response, "Login request rejected by authorizor"); throw error; } else if (response.StatusCode != HttpStatusCode.OK) { LoginPostFailed error = new LoginPostFailed(response, "Web Status not ok"); throw error; } return(response); }
public async Task <HttpResponseMessage> SettingsPost(FormUrlEncodedContent values = null) { HttpResponseMessage response = null; if (values == null) { values = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("EnvironmentConfiguration.SummerSchool", "false"), new KeyValuePair <string, string>("EnvironmentConfiguration.Database", "10"), new KeyValuePair <string, string>("EnvironmentConfiguration.SchoolYear", ""), new KeyValuePair <string, string>("EnvironmentConfiguration.UserMayImpersonate", "false"), new KeyValuePair <string, string>("okButton", "") }); } response = await client.MakePost(values, extensionURL); //logic to determine if we really succeeded // throw new PostFailed(response); if (response == null) { PostFailed error = new PostFailed(response, "Post response null"); throw error; } else if (response.RequestMessage.RequestUri.ToString().IndexOf(extensionURL) != -1) { SetSessionPostFailed error = new SetSessionPostFailed(response, "Login request rejected by authorizor"); throw error; } else if (response.StatusCode != HttpStatusCode.OK) { SetSessionPostFailed error = new SetSessionPostFailed(response, "Web status not ok"); throw error; } return(response); }