private async Task <string> CreateUserAsync(string url) { VisibleProgress(Resource.Id.pbHeaderProgress, VISIBLE); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url)); request.ContentType = "application/json"; request.Method = "POST"; using (var streamWriter = new StreamWriter(request.GetRequestStream())) { jsonUser = jbService.jsonCreateUser(createUserByScreen()); streamWriter.Write(jsonUser); streamWriter.Flush(); streamWriter.Close(); } using (WebResponse response = await request.GetResponseAsync()) { using (Stream stream = response.GetResponseStream()) { var serializer = new JsonSerializer(); var sr = new StreamReader(stream); var jsonTextReader = new JsonTextReader(sr); var json = serializer.Deserialize(jsonTextReader); string msgObj = JsonConvert.SerializeObject(json); return(msgObj); } } }
private void BtnUpdate_Click(object sender, EventArgs e) { User user = createUserByScreen(); jsonUser = jbService.jsonCreateUser(user); appPreferences.saveKey(AppPreferences.USER, jsonUser); appPreferences.saveKey(AppPreferences.AVATAR, avatarBase64String); var vCard = xmppFace.saveVCard(user, appPreferences, avatarBase64String); Task.Run(() => this.App.Xmpp.SetMyVCard(vCard)); Toast.MakeText(ApplicationContext, GetString(Resource.String.success), ToastLength.Short).Show(); }