public static Responce ResponeNull() { Responce resp = new Responce(); resp.Executed = false; resp.Result = null; return(resp); }
internal object GetResponceObject(Responce responce) { if (responce.Result.ToString().StartsWith("{", StringComparison.Ordinal) & responce.Result.ToString().EndsWith("}", StringComparison.Ordinal)) { Result result = JsonConvert.DeserializeObject <Result>(responce.Result.ToString()); return(result); } else { return(responce.Result.ToString()); } }
internal Responce ReadResponse() { if (HttpResponse != null) { using (var streamReader = new StreamReader(HttpResponse.GetResponseStream())) { string json = streamReader.ReadToEnd(); Console.WriteLine(json); Responce deserializedResponce = JsonConvert.DeserializeObject <Responce>(json); return(deserializedResponce); } } else { return(Responce.ResponeNull()); } }
async void Button_Registrieen_Clicked(object sender, EventArgs e) { User user = new User(); user.Email = Entry_Email.Text; user.Benutzername = Entry_Benutzername.Text; if (string.Equals(Entry_Password.Text, Entry_Password_Wiederholen.Text)) { user.Passwort = Entry_Password.Text; } else { //DisplayAlert(); return; } string json = request.CreateJsonObject(RequestTyp.Registrierung, user); await DisplayAlert("Json", json, "Ok"); object repo = request.Execute(json); Responce responce = (Responce)repo; string result = request.GetResponceObject(responce).ToString(); if (responce.Executed) { await DisplayAlert("Info", result, "Ok"); if (result == "Benutzer regristriert") { await Navigation.PushAsync(new LoginsPage(user.Email)); } } else { await DisplayAlert("Error", "Keine Verbindung mit dem Server", "Ok"); } }
async void Button_Loggin_Login_Clicked(object sender, System.EventArgs e) { User user = new User(); user.Email = Entry_Benutzername.Text; user.Passwort = Entry_Password.Text; string json = request.CreateJsonObject(RequestTyp.Loggin, user); await DisplayAlert("Op", json, "kd"); object repo = request.Execute(json); Responce responce = (Responce)repo; await DisplayAlert("yo", responce.Result.ToString(), "Ok"); Result result = (Result)request.GetResponceObject(responce); if (responce.Executed) { if (result.LoggedIn) { user = result.User; await Navigation.PushAsync(new HomePage(user)); } else { await DisplayAlert("Error", "Email oder Passwort falsch", "Ok"); Entry_Password.Text = ""; Entry_Benutzername.Focus(); } } else { await DisplayAlert("Error", "Keine Verbindung mit dem Server", "Ok"); } }
async void Add_clicked(object sender, EventArgs e) { ButtonUser button = sender as ButtonUser; string json = request.CreateJsonObject(RequestTyp.ConfirmDemand, aktUser, button.IdUser); await DisplayAlert("Josn", json, "Ok"); object repo = request.Execute(json); Responce responce = (Responce)repo; string result = request.GetResponceObject(responce).ToString(); if (responce.Executed) { button.IsEnabled = false; AddOneElementGridHome(ListFriendsToConfirm[button.IdUser]); } else { await DisplayAlert("Error", "Keine Verbindung mit dem Server", "Ok"); } }