From 10cf3ca9c08b25c5fd72115441779c26985ea08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przyby=C5=82a?= Date: Mon, 21 Dec 2020 16:26:48 +0100 Subject: [PATCH] POS-32 Poprwka --- Klient/Klient/Klient.Android/MainActivity.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Klient/Klient/Klient.Android/MainActivity.cs b/Klient/Klient/Klient.Android/MainActivity.cs index e25828f..f7e9564 100644 --- a/Klient/Klient/Klient.Android/MainActivity.cs +++ b/Klient/Klient/Klient.Android/MainActivity.cs @@ -66,7 +66,13 @@ namespace Klient.Droid if (response.StatusCode == HttpStatusCode.OK) { savedLogin = Login; + var jsonString = await response.Content.ReadAsStringAsync(); + dynamic jsonObject = JsonConvert.DeserializeObject(jsonString); SetContentView(Resource.Layout.ekranPoLogowaniu); + savedName = jsonObject.user.name; + savedEmail = jsonObject.user.email; + savedSurname = jsonObject.user.surname; + } } @@ -177,12 +183,18 @@ namespace Klient.Droid var Surname = FindViewById(Resource.Id.ChangeSurname).Text; var Email = FindViewById(Resource.Id.ChangeEmail).Text; - if (string.IsNullOrEmpty(Name) | string.IsNullOrEmpty(Email) | string.IsNullOrEmpty(Surname)) + if (string.IsNullOrEmpty(Name)) { - FindViewById(Resource.Id.NullValueProfile).Text = "Wartości nie mogą być puste!"; + Name = savedName; } - else + if (string.IsNullOrEmpty(Email)) { + Email = savedEmail; + } + if (string.IsNullOrEmpty(Surname)) + { + Surname = savedSurname + } var values = new Dictionary { { "email", Email }, @@ -197,7 +209,7 @@ namespace Klient.Droid var responseString = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK) FindViewById(Resource.Id.NullValueProfile).Text = "Zapisano!"; - } + } } } \ No newline at end of file