private async void Sendtext_ClickAsync(object sender, EventArgs e) { datetime = DateTime.Now.ToLocalTime(); SendMessages sendMessageJson = new SendMessages(); if (IsDoctor == false) // to ID tou asthenh prepei na stalei prwto { sendMessageJson.PatientID = myID; sendMessageJson.DoctorID = receiverID; sendMessageJson.Sender = 0; } else { sendMessageJson.PatientID = receiverID; sendMessageJson.DoctorID = myID; sendMessageJson.Sender = 1; } sendMessageJson.Text = message2.Text; sendMessageJson.Seen = false; sendMessageJson.Date = datetime.ToString(); sendMessageJson.Send = false; string output = JsonConvert.SerializeObject(sendMessageJson); Address address = new Address(); string endpoint = address.Endpoint + "DataSenders"; var uri = new Uri(endpoint); var StrRespPost = await PostRest.Post(output, uri, true); if (StrRespPost == "Created") // tsekare to giati mporei na stalei kai na epistrepsei diaforetiko mhnuma { new AlertDialog.Builder(this) .SetMessage("Successfully Send") .SetTitle("Message") .Show(); } else { new AlertDialog.Builder(this) .SetMessage("Unsuccessfull Send!!" + "\n" + "Something went wrong" + "\n" + StrRespPost) .SetTitle("Message") .SetIcon(Resource.Drawable.error) .Show(); } }
private async void Button1_ClickAsync(object sender, EventArgs e) { String InsertUser = Username.Text; String InsertPasw = Password.Text; string endpoint1; PostRest p = new PostRest(); Address address = new Address(); endpoint1 = address.Endpoint + "Users"; var uri = new Uri(endpoint1); Usercheck usercheck = new Usercheck(); usercheck.UserName = InsertUser; usercheck.Password = InsertPasw; string output = JsonConvert.SerializeObject(usercheck); var StrRespPost = await PostRest.Post(output, uri, false); ValidateJson validatejson = new ValidateJson(); bool valid = validatejson.IsValidJson(StrRespPost); if (valid) { try { UserIdentity userident = JsonConvert.DeserializeObject <UserIdentity>(StrRespPost.ToString()); IsDoctor = userident.IsDoctor; myId = userident.PersonID; SaveBool(IsDoctor); //save in Shared Preferences if it is Doctor if (IsDoctor) { var intent = new Intent(this, typeof(DemographicsDoctorActivity)); intent.PutExtra("myID", myId); StartActivity(intent); } else { var intent = new Intent(this, typeof(DemographicActivity)); intent.PutExtra("myID", myId); StartActivity(intent); } } catch { txt2.Text = "Unsuccessfull Login due to an error"; } } else if (StrRespPost == "NotFound") { txt2.Text = "Error" + "\n" + "Unsuccessfull Login UserName or Password isn't valid ," + StrRespPost; txt2.SetTextColor(Color.Red); Password.Text = ""; } else { txt2.Text = "An error occured :" + "\n" + StrRespPost; txt2.SetTextColor(Color.Red); } }