private async void Regbtn_Clicked(object sender, EventArgs e) { Active.IsRunning = true; StringContent user_id = new StringContent(Settings.LastUsedDriverID.ToString()); StringContent car_model_id = new StringContent(Settings.CarModelID); StringContent lat = new StringContent(Settings.LastLat); StringContent lang = new StringContent(Settings.LastLng); var content = new MultipartFormDataContent(); content.Add(user_id, "user_id"); content.Add(lat, "lat"); content.Add(lang, "lang"); content.Add(car_model_id, "car_model_id"); content.Add(new StreamContent(ProfilePic.GetStream()), "personal_image", $"{ProfilePic.Path}"); content.Add(new StreamContent(NationalImg1.GetStream()), "national_id_front", $"{NationalImg1.Path}"); content.Add(new StreamContent(NationalImg2.GetStream()), "national_id_behind", $"{NationalImg2.Path}"); content.Add(new StreamContent(DriverLicImg.GetStream()), "driving_license", $"{DriverLicImg.Path}"); content.Add(new StreamContent(CarLicImg.GetStream()), "car_license", $"{CarLicImg.Path}"); content.Add(new StreamContent(CarImg.GetStream()), "car_img", $"{CarImg.Path}"); var httpClient = new HttpClient(); try { var httpResponseMessage = await httpClient.PostAsync("http://wassel.alsalil.net/api/driverRegister", content); var serverResponse = httpResponseMessage.Content.ReadAsStringAsync().Result.ToString(); var json = JsonConvert.DeserializeObject <Response <string, string> >(serverResponse); if (json.success == false) { Active.IsRunning = false; await DisplayAlert(AppResources.Error, json.message, AppResources.Ok); } else { Active.IsRunning = false; await DisplayAlert(json.message, AppResources.RegisterSuccess, AppResources.Ok); Device.BeginInvokeOnMainThread(() => App.Current.MainPage = new LoginPage()); } } catch (Exception) { Active.IsRunning = false; await DisplayAlert(AppResources.ErrorMessage, AppResources.ErrorMessage, AppResources.Ok); } }
private async void NationalBack_Clicked(object sender, EventArgs e) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsPickPhotoSupported) { await DisplayAlert("خطأ", "لم يتم إلتقاط صور", "موافق"); return; } NationalImg2 = await CrossMedia.Current.PickPhotoAsync(); if (NationalImg2 == null) { return; } NatBackImgSource.Source = ImageSource.FromStream(() => { return(NationalImg2.GetStream()); }); }