private async void Button_SaveOnClicked(object sender, EventArgs e) { string tmp = MyEntry.Text; if (tmp != null) { Match match = regex.Match(tmp); if (match.Success) { var r = new CoAdminResources(); var admin = new CoAdmin { Email = tmp }; await r.PostAdminAsync(admin); await Navigation.PopAsync(); } else { await DisplayAlert(L10n.Localize("AlertLabel"), L10n.Localize("ValidationAlert"), L10n.Localize("OkAction")); } } else { await DisplayAlert(L10n.Localize("AlertLabel"), L10n.Localize("NullAlert"), L10n.Localize("OkAction")); } }
public async Task PostAdminAsync(CoAdmin admin) { var client = new HttpClient(); client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", App.USERTOKEN); var httpUrl = "https://izy.meazon.com/api/energylog/userCoAdmins"; var jsonData = JsonConvert.SerializeObject(admin); HttpContent content = new StringContent(jsonData); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var smth = await client.PostAsync(httpUrl, content); var sthnew = smth.IsSuccessStatusCode; }