async void UploadProperty() { //checking for connectivity var network = Connectivity.NetworkAccess; if (network != NetworkAccess.Internet) { await MaterialDialog.Instance.SnackbarAsync(message : "Error: No internet access", actionButtonText : "OK", msDuration : 3000, configuration : snackBarConfiguration); return; } if (string.IsNullOrEmpty(ItemName) || string.IsNullOrEmpty(Location) || Price == 0M || string.IsNullOrEmpty(Description) || string.IsNullOrEmpty(Type)) { await MaterialDialog.Instance.SnackbarAsync(message : "Error: Fill the required fields", actionButtonText : "OK", msDuration : 3000, configuration : snackBarConfiguration); return; } IsBusy = false; var loadingPageConfiguration = new MaterialLoadingDialogConfiguration() { BackgroundColor = Color.FromHex("1DA1F2"), MessageTextColor = Color.FromHex("FFFFFF"), CornerRadius = 10, TintColor = Color.FromHex("FFFFFF"), ScrimColor = Color.FromHex("1DA1F2").MultiplyAlpha(0.32) }; var loadingDialog = await MaterialDialog.Instance.LoadingDialogAsync(message : "Processing", configuration : loadingPageConfiguration); if (image1 == 1) { firstImageUrl = await remoteService.UploadFile(mediaFile1.GetStream(), Path.GetFileName(mediaFile1.Path)); } if (image2 == 1) { secondImageUrl = await remoteService.UploadFile(mediaFile2.GetStream(), Path.GetFileName(mediaFile2.Path)); } if (image3 == 1) { thirdImageUrl = await remoteService.UploadFile(mediaFile3.GetStream(), Path.GetFileName(mediaFile3.Path)); } if (image4 == 1) { fourthImageUrl = await remoteService.UploadFile(mediaFile4.GetStream(), Path.GetFileName(mediaFile4.Path)); } //firstImageUrl = await remoteService.UploadFile(mediaFile1.GetStream(), Path.GetFileName(mediaFile1.Path)); //secondImage = await remoteService.UploadFile(mediaFile2.GetStream(), Path.GetFileName(mediaFile2.Path)); //thirdImageUrl = await remoteService.UploadFile(mediaFile3.GetStream(), Path.GetFileName(mediaFile3.Path)); //fourthImageUrl = await remoteService.UploadFile(mediaFile4.GetStream(), Path.GetFileName(mediaFile4.Path)); var realtorProperty = new RealtorProperty() { CompanyName = Settings.CompanyNameSettings, AccountName = Settings.UsernameSettings, Avatar = Settings.AvatarSettings, ItemName = this.ItemName.ToLower().Trim(), ItemPrice = this.Price, Description = this.Description.ToLower().Trim(), Location = this.Location.ToLower().Trim(), ItemType = this.Type, Negotiable = this.Negotiable, PhoneNumber = Settings.PhoneNumberSettings, Email = Settings.EmailSettings, FirstImage = firstImageUrl, SecondImage = secondImageUrl, ThirdImage = thirdImageUrl, FourthImage = fourthImageUrl, IsFavorite = false }; var upload = await remoteService.AddProperty(realtorProperty); await loadingDialog.DismissAsync(); IsBusy = true; if (upload) { ItemName = null; Price = 0; Description = null; Location = null; Type = null; Negotiable = null; FirstImage.Source = "Upload.png"; SecondImage.Source = "Upload.png"; ThirdImage.Source = "Upload.png"; FourthImage.Source = "Upload.png"; await MaterialDialog.Instance.SnackbarAsync(message : "Uploaded successfully", actionButtonText : "OK", msDuration : 3000, configuration : snackBarConfiguration); } else { await MaterialDialog.Instance.SnackbarAsync(message : "Uploaded failed", actionButtonText : "OK", msDuration : 3000, configuration : snackBarConfiguration); } //IsBusy = true; }