private async void SaveFacility() { if (appPreferences.IsOnline(Application.Context)) { facility.SettlementType = settlementtype.SelectedItem.ToString(); facility.Zoning = zoning.SelectedItem.ToString(); MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); bool isUpdated = await viewModel.ExecuteUpdateFacilityCommand(facility); messageDialog.HideLoading(); if (isUpdated) { messageDialog.SendToast("Facility Information is saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(facility.Id.ToString()); intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(facility)); this.StartActivity(intent); Finish(); } else { messageDialog.SendToast("Error occurred: Unable to save Facility Information."); } } }
async void SaveButton_Click(object sender, EventArgs e) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); facility.SettlementType = settlementtype.SelectedItem.ToString(); facility.Zoning = zoning.SelectedItem.ToString(); bool isUpdated = await ViewModel.ExecuteUpdateFacilityCommand(facility); if (isUpdated) { editButton.Visibility = ViewStates.Visible; saveButton.Visibility = ViewStates.Gone; isEdit = false; settlementtype.Enabled = false; zoning.Enabled = false; messageDialog.HideLoading(); messageDialog.SendToast("Facility is updated successful."); } else { messageDialog.HideLoading(); messageDialog.SendToast("Facility is not updated successful."); } this.isEdit = false; }
async void Submit_Click(Facility facility) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); BuildingsViewModel ViewModel = new BuildingsViewModel(); await ViewModel.ExecuteBuildingsCommand(facility.Id); var buildings = ViewModel.Buildings; if (!ValidateForm(facility, buildings, messageDialog)) { messageDialog.HideLoading(); return; } facility.Status = "Submitted"; facility.ModifiedUserId = userId; facility.ModifiedDate = new DateTime(); bool isUpdated = await viewModel.ExecuteUpdateFacilityCommand(facility); messageDialog.HideLoading(); if (isUpdated) { viewModel.Facilities.Remove(viewModel.Facilities.Where(s => s.Id == facility.Id).Single()); messageDialog.SendToast("Facility is submitted for approval."); var myActivity = (MainActivity)this.activity; myActivity.Recreate(); } else { messageDialog.SendToast("Unable to submitted facility for approval."); } }
public async void SubmitFacility() { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); BuildingsViewModel ViewModel = new BuildingsViewModel(); await ViewModel.ExecuteBuildingsCommand(facility.Id); var buildings = ViewModel.Buildings; if (!ValidateForm(facility, buildings.ToList(), messageDialog)) { messageDialog.HideLoading(); return; } facility.Status = "Submitted"; facility.ModifiedUserId = userId; facility.ModifiedDate = new DateTime(); bool isUpdated = await viewModel.ExecuteUpdateFacilityCommand(facility); messageDialog.HideLoading(); if (isUpdated) { messageDialog.SendToast("Facility is submitted for approval."); var intent = new Intent(Activity, typeof(MainActivity)); StartActivity(intent); } else { messageDialog.SendToast("Unable to submit facility for approval."); } }
private void BPLocationButton_Click(object sender, EventArgs eventArgs) { GPSTracker GPSTracker = new GPSTracker(); Android.Locations.Location location = GPSTracker.GPSCoordinate(); if (!GPSTracker.isLocationGPSEnabled) { ShowSettingsAlert(); } if (location == null) { MessageDialog messageDialog = new MessageDialog(); messageDialog.SendToast("Unable to get location"); } else { BoundryPolygon BoundryPolygon = new BoundryPolygon() { Latitude = location.Latitude.ToString(), Longitude = location.Longitude.ToString() }; _BoundryPolygons.Add(BoundryPolygon); itemList.Add("Lat: " + location.Latitude.ToString() + " Long: " + location.Longitude.ToString()); boundaryPolygonsText.Text = String.Format("Boundary Polygons {0}", itemList.Count); arrayAdapter = new ArrayAdapter <string>(Activity, Resource.Layout.list_item, itemList); bpListView.Adapter = arrayAdapter; bpListView.ItemLongClick += Adapter_ItemSwipe; int listViewMinimumHeight = 25 * _BoundryPolygons.Count(); bpListView.SetMinimumHeight(listViewMinimumHeight); } }
void AddLocation_Click(object sender, EventArgs e) { GPSTracker GPSTracker = new GPSTracker(); Android.Locations.Location location = GPSTracker.GPSCoordinate(); if (!GPSTracker.isLocationGPSEnabled) { ShowSettingsAlert(); } if (location == null) { MessageDialog messageDialog = new MessageDialog(); messageDialog.SendToast("Unable to get location"); } else { locationLinearlayout.Visibility = ViewStates.Visible; tvbLatitude.Text = "Lat: " + location.Latitude.ToString(); tvbLongitude.Text = "Long: " + location.Longitude.ToString(); accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString()); _GPSCoordinates = new GPSCoordinate() { Latitude = location.Latitude.ToString(), Longitude = location.Longitude.ToString() }; building.GPSCoordinates = _GPSCoordinates; } }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); SupportActionBar.Title = "Quotes"; MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); var request = Intent.GetStringExtra("request"); Request item = JsonConvert.DeserializeObject <Request>(request); Request = new Request(); Request = item; quotesViewModel = new QuotesViewModel(); await quotesViewModel.GetQuotes(Request); if (quotesViewModel.Quotes.Count > 0) { var contactsAdapter = new ContactsAdapter(this, quotesViewModel.Quotes); var contactsListView = FindViewById <ListView>(Resource.Id.ContactsListView); contactsListView.Adapter = contactsAdapter; contactsListView.ItemClick += ItemClick; SaveQuoteRequest(quotesViewModel.Quotes, Request, quotesViewModel); } else { messageDialog.SendToast("There are no couriers available within 50KM from your pick up location."); Intent intent = new Intent(this, typeof(RequestCourierActivity)); StartActivity(intent); } messageDialog.HideLoading(); }
private async void SendOTPButton_Click(object sender, EventArgs e) { message.Text = ""; Validations validation = new Validations(); MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (!validation.IsValidEmail(username.Text.Trim())) { message.Text = "Please enter username to send one time pin"; messageDialog.HideLoading(); return; } int pin = Convert.ToInt32(GetRandomNumber(5)); await ViewModel.SetOPTForUsersync(username.Text.Trim(), pin); if (ViewModel.Respond.ErrorOccurred) { message.Text = ViewModel.Respond.Error.Message; changePasswordButton.Visibility = ViewStates.Gone; } else { messageDialog.SendToast("One time pin is sent successfully."); changePasswordButton.Visibility = ViewStates.Visible; string smsMessase = string.Format("Send Me: Confirmation OTP:{0}. Change password", pin); messageDialog.SendSMS(ViewModel.Respond.User.Courier.MobileNumber.Trim(), smsMessase); } messageDialog.HideLoading(); }
private void GPSLocationButton_Click(object sender, EventArgs eventArgs) { GPSTracker GPSTracker = new GPSTracker(); Android.Locations.Location location = GPSTracker.GPSCoordinate(); if (!GPSTracker.isLocationGPSEnabled) { ShowSettingsAlert(); } if (location == null) { MessageDialog messageDialog = new MessageDialog(); messageDialog.SendToast("Unable to get location"); } else { tvfLatLong.Text = "Lat: " + location.Latitude.ToString() + " Long: " + location.Longitude.ToString(); accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString()); Location.GPSCoordinates = new GPSCoordinate() { Longitude = location.Longitude.ToString(), Latitude = location.Latitude.ToString() }; } }
private bool ValidateLocation() { Validations validation = new Validations(); MessageDialog messageDialog = new MessageDialog(); Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error); icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight); bool isValid = true; if (!validation.IsRequired(streetAddress.Text)) { streetAddress.SetError("This field is required", icon); isValid = false; } if (!validation.IsRequired(suburb.Text)) { suburb.SetError("This field is required", icon); isValid = false; } if (facility.Location == null) { if (facility.Location.GPSCoordinates == null) { messageDialog.SendToast("Please add an GPS coordinates"); isValid = false; } } return(isValid); }
private async void ChangePasswordButton_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); EncryptionHelper encryptionHelper = new EncryptionHelper(); message.Text = ""; var _user = new User() { Username = username.Text, Password = encryptionHelper.Encrypt(password.Text, "Passw0rd@SendMe"), }; await ViewModel.ChangePasswordAsync(_user, Convert.ToInt32(oneTimePin.Text.Trim())); if (ViewModel.Respond.ErrorOccurred) { message.Text = ViewModel.Respond.Error.Message; } else { messageDialog.SendToast("Password is changed successfully."); Finish(); } messageDialog.HideLoading(); }
private async void SaveDeedInfor() { if (appPreferences.IsOnline(Application.Context)) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (!ValidateDeedInfo()) { messageDialog.HideLoading(); return; } DeedsInfo.ErFNumber = erfNumber.Text; DeedsInfo.TitleDeedNumber = titleDeedNumber.Text; DeedsInfo.Extent = extentm2.Text; DeedsInfo.OwnerInfomation = ownerInformation.Text; DeedsInfo.FacilityId = Facility.Id; DeedsInfo.CreatedUserId = userId; DeedsInfo.ModifiedDate = DateTime.Now; DeedsInfo.ModifiedUserId = userId; DeedsInfo.CreatedDate = DateTime.Now; bool isSuccess = await ViewModel.AddUpdateDeedsInfoAsync(DeedsInfo); messageDialog.HideLoading(); if (isSuccess) { messageDialog.SendToast("Deeds information is saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); appPreferences.SaveFacilityId(Facility.Id.ToString()); Facility.Buildings = new List <Building>(); Facility.DeedsInfo = DeedsInfo; intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(Facility)); this.StartActivity(intent); Finish(); } else { messageDialog.SendToast("Error occurred: Unable to save deed information."); } } }
private async void SaveLocation() { if (appPreferences.IsOnline(Application.Context)) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (!ValidateLocation()) { messageDialog.HideLoading(); return; } Location.LocalMunicipality = localmunicipality.SelectedItem.ToString(); Location.Province = province.SelectedItem.ToString(); Location.StreetAddress = streetAddress.Text; Location.Suburb = suburb.Text; Location.Region = region.Text; Location.BoundryPolygon = _BoundryPolygons; Location.FacilityId = Facility.Id; bool isSuccess = await ViewModel.AddUpdateLocationAsync(Location); messageDialog.HideLoading(); if (isSuccess) { messageDialog.SendToast("Location is saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(Facility.Id.ToString()); Facility.Buildings = new List <Building>(); Facility.Location = Location; intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(Facility)); this.StartActivity(intent); Finish(); } else { messageDialog.SendToast("Error occurred: Unable to save location."); } } }
private async void SavePerson() { if (appPreferences.IsOnline(Application.Context)) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); Person.FullName = fullname.Text; Person.Designation = designation.Text; Person.PhoneNumber = mobileNumber.Text; Person.EmailAddress = emailaddress.Text; Person.FacilityId = Facility.Id; Person.CreatedUserId = userId; Person.ModifiedDate = DateTime.Now; Person.ModifiedUserId = userId; Person.CreatedDate = DateTime.Now; bool isSuccess = await ViewModel.AddUpdatePersonAsync(Person); messageDialog.HideLoading(); if (isSuccess) { messageDialog.SendToast("Responsible person is saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(Facility.Id.ToString()); Facility.Buildings = new List <Building>(); Facility.ResposiblePerson = Person; intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(Facility)); this.StartActivity(intent); Finish(); } else { messageDialog.SendToast("Error occurred: Unable to save responsible person."); } } }
private async void SignUpButton_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); message.Text = ""; EncryptionHelper encryptionHelper = new EncryptionHelper(); var _user = new User() { Username = username.Text.Trim(), DisplayName = displayName.Text.Trim(), Password = encryptionHelper.Encrypt(password.Text.Trim(), "Passw0rd@SendMe"), UserTypeId = 3, ProfilePicture = Logo, Courier = new Courier() { VehicleBodyTypes = mSelectedItems, MobileNumber = courierMobileNumber.Text.Trim(), PricePerKM = Convert.ToDouble(pricePerKM.Text.Trim()), }, }; await ViewModel.SignUpUser(_user); if (ViewModel.Respond.ErrorOccurred) { message.Text = ViewModel.Respond.Error.Message; } else { messageDialog.SendToast("You are now registered to provide your service, Login to start making money"); Finish(); } messageDialog.HideLoading(); }
async Task ExecuteSaveCommand() { if (IsBusy) { return; } IsBusy = true; var newItem = new MyItem { Text = Item.Text, Description = Item.Description, Quantity = Quantity }; try { if (!Settings.IsLoggedIn) { if (!await LoginViewModel.TryLoginAsync(StoreManager)) { return; } } await StoreManager.MyItemStore.InsertAsync(newItem); MyItemsViewModel.IsDirty = true; IsBusy = false; OnFinished?.Invoke(Item); MessageDialog.SendToast("Item has been saved to My Items list."); } finally { IsBusy = false; } }
private async void SignUpButton_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); message.Text = ""; var _user = new User() { Username = User.Username, DisplayName = displayName.Text.Trim(), ProfilePicture = Logo, Courier = new Courier() { VehicleBodyTypes = mSelectedItems, MobileNumber = courierMobileNumber.Text.Trim(), PricePerKM = Convert.ToDouble(pricePerKM.Text.Trim()), }, }; await ViewModel.UpdateUserAsync(_user); if (ViewModel.Respond.ErrorOccurred) { message.Text = ViewModel.Respond.Error.Message; } else { messageDialog.SendToast("Profile is updated successfully."); Finish(); } messageDialog.HideLoading(); }
private bool ValidateForm() { Validations validation = new Validations(); Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error); icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight); bool formIsValid = true; if (vehiclebodytype.SelectedItem.ToString() == "Select Vehicle Body Type") { MessageDialog messageDialog = new MessageDialog(); messageDialog.SendToast("Please Select Vehicle Body Type"); formIsValid = false; } if (!validation.IsValidEmail(email.Text)) { email.SetError("Invalid email address", icon); formIsValid = false; } if (!validation.IsValidPhone(phone.Text)) { phone.SetError("Invaild phone number", icon); formIsValid = false; } if (!validation.IsRequired(name.Text)) { name.SetError("This field is required", icon); formIsValid = false; } if (!validation.IsRequired(pickupLocation.Text)) { pickupLocation.SetError("This field is required", icon); formIsValid = false; } else { var pickupLocationPlaceId = PickUpLocations.FirstOrDefault(l => l.Description.Trim() == pickupLocation.Text.Trim()); if (pickupLocationPlaceId == null) { pickupLocation.SetError("Unable to get your pick up location", icon); formIsValid = false; } else { fromLocation = GetLocationDetails(pickupLocationPlaceId.PlaceId, pickupLocation.Text.Trim()); } } if (!validation.IsRequired(dropLocation.Text)) { dropLocation.SetError("This field is required", icon); formIsValid = false; } else { var dropLocationPlaceId = DropLocations.FirstOrDefault(l => l.Description.Trim() == dropLocation.Text.Trim()); if (dropLocationPlaceId == null) { dropLocation.SetError("Unable to get your drop location", icon); formIsValid = false; } else { tolocation = GetLocationDetails(dropLocationPlaceId.PlaceId, pickupLocation.Text.Trim()); } } return(formIsValid); }
private bool ValidateForm() { Validations validation = new Validations(); Android.Graphics.Drawables.Drawable icon = Resources.GetDrawable(Resource.Drawable.error); icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight); FormIsValid = true; if (string.IsNullOrEmpty(Logo)) { MessageDialog messageDialog = new MessageDialog(); messageDialog.SendToast("Select Profile Picture"); FormIsValid = false; } if (mSelectedItems == null) { MessageDialog messageDialog = new MessageDialog(); messageDialog.SendToast("Please Choose Your Vehicle Body Type"); FormIsValid = false; } if (!validation.IsValidEmail(username.Text)) { username.SetError("Invalid email address", icon); FormIsValid = false; } if (!validation.IsValidPassword(password.Text)) { password.SetError("Password cannot be empty and length must be greater than 6 characters", icon); FormIsValid = false; } if (!validation.IsValidPassword(confirmPassword.Text)) { confirmPassword.SetError("Password cannot be empty and length must be greater than 6 characters", icon); FormIsValid = false; } if (confirmPassword.Text != password.Text) { confirmPassword.SetError("Password and confirm password don't match", icon); FormIsValid = false; } if (!validation.IsValidPhone(courierMobileNumber.Text)) { courierMobileNumber.SetError("Invaild phone number", icon); FormIsValid = false; } if (!validation.IsRequired(pricePerKM.Text)) { pricePerKM.SetError("This field is required", icon); FormIsValid = false; } if (!validation.IsRequired(displayName.Text)) { displayName.SetError("This field is required", icon); FormIsValid = false; } return(FormIsValid); }
private bool ValidateForm(Facility facility, ObservableCollection <Building> buildings, MessageDialog messageDialog) { Validations validation = new Validations(); bool isValid = true; bool deedsInfoIsRequired = false; bool locationfoIsRequired = false; bool pictureIsRequired = false; bool buildingPictureIsRequired = false; bool buildingLocationIsRequired = false; foreach (var building in buildings) { if (String.IsNullOrEmpty(building.Photo)) { buildingPictureIsRequired = true; isValid = false; } if (building.GPSCoordinates == null) { buildingLocationIsRequired = true; isValid = false; } } if (facility.DeedsInfo == null) { deedsInfoIsRequired = true; isValid = false; } if (facility.Location == null) { locationfoIsRequired = true; isValid = false; } if (!validation.IsRequired(facility.IDPicture)) { pictureIsRequired = true; isValid = false; } if (deedsInfoIsRequired || locationfoIsRequired || pictureIsRequired || buildingLocationIsRequired || buildingPictureIsRequired) { if (deedsInfoIsRequired && locationfoIsRequired && pictureIsRequired) { messageDialog.SendToast("Please add an image, location information and deeds information"); } else if (deedsInfoIsRequired) { messageDialog.SendToast("Please capture deeds information."); } else if (locationfoIsRequired) { messageDialog.SendToast("Please capture location information."); } else if (pictureIsRequired) { messageDialog.SendToast("Please add an image."); } else if (buildingPictureIsRequired && buildingLocationIsRequired) { messageDialog.SendToast("Please add an image and location for all the buildings."); } else if (buildingPictureIsRequired) { messageDialog.SendToast("Please add an image for all the buildings."); } else if (buildingLocationIsRequired) { messageDialog.SendToast("Please add location for all the buildings."); } } return(isValid); }
private async void SaveFacility() { if (appPreferences.IsOnline(Application.Context)) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (imageNames.Count() == 0) { imageNames = new List <string>(); } if (FirstPhotoIsChanged) { string thisFileName = appPreferences.SaveImage(((BitmapDrawable)facilityPhoto.Drawable).Bitmap); if (imageNames.Count() > 0) { imageNames[0] = thisFileName; } else { imageNames.Add(thisFileName); } } if (SecondPhotoIsChanged) { var _fileName = String.Format("facility_{0}", Guid.NewGuid()); appPreferences.SaveImage(((BitmapDrawable)secondFacilityPhoto.Drawable).Bitmap, _fileName); if (imageNames.Count() > 1) { imageNames[1] = _fileName; } else { imageNames.Add(_fileName); } } if (FirstPhotoIsChanged) { facility.IDPicture = ""; foreach (var name in imageNames) { if (!String.IsNullOrEmpty(name)) { if (String.IsNullOrEmpty(facility.IDPicture)) { facility.IDPicture = name; } else { facility.IDPicture = facility.IDPicture + "," + name; } } } } bool isUpdated = await ViewModel.ExecuteUpdateFacilityCommand(facility); if (isUpdated) { PictureViewModel pictureViewModel = new PictureViewModel(); List <Models.Picture> pictures = new List <Models.Picture>(); if (FirstPhotoIsChanged) { Bitmap _bm = ((BitmapDrawable)facilityPhoto.Drawable).Bitmap; string file = ""; if (_bm != null) { MemoryStream stream = new MemoryStream(); _bm.Compress(Bitmap.CompressFormat.Jpeg, 100, stream); byte[] ba = stream.ToArray(); file = Base64.EncodeToString(ba, Base64.Default); } Models.Picture picture = new Models.Picture() { Name = imageNames[0], File = file, }; pictures.Add(picture); } if (SecondPhotoIsChanged && imageNames.Count() > 1) { Bitmap _bm = ((BitmapDrawable)secondFacilityPhoto.Drawable).Bitmap; string file = ""; if (_bm != null) { MemoryStream stream = new MemoryStream(); _bm.Compress(Bitmap.CompressFormat.Jpeg, 100, stream); byte[] ba = stream.ToArray(); file = Base64.EncodeToString(ba, Base64.Default); } Models.Picture picture = new Models.Picture() { Name = imageNames[1], File = file, }; pictures.Add(picture); } bool isSuccess = await pictureViewModel.ExecuteSavePictureCommand(pictures); messageDialog.HideLoading(); messageDialog.SendToast("Pictures are saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(facility.Id.ToString()); intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(facility)); this.StartActivity(intent); Finish(); } else { messageDialog.HideLoading(); messageDialog.SendToast("Pictures are not saved successful."); } } }
async void SaveButton_Click(object sender, EventArgs e) { MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); if (!ValidateForm()) { messageDialog.HideLoading(); return; } StaticData staticData = new StaticData(); int numberOfFloors = 0; if (!String.IsNullOrEmpty(nooOfFoors.Text)) { numberOfFloors = Convert.ToInt32(nooOfFoors.Text); } if (PhotoIsChanged) { FileName = SaveImage(((BitmapDrawable)buildingPhoto.Drawable).Bitmap); } Building item = new Building { Id = building.Id, BuildingName = buildingName.Text, BuildingNumber = building.Id == 0 ? facilityId + staticData.RandomDigits(10) : building.BuildingNumber, BuildingType = buildingType.SelectedItem.ToString(), BuildingStandard = buildingstandard.SelectedItem.ToString(), Status = utilisationStatus.Text, NumberOfFloors = numberOfFloors, FootPrintArea = Convert.ToDouble(totalFootprintAream2.Text), ImprovedArea = Convert.ToDouble(totalImprovedaAeam2.Text), Heritage = heritage.Checked == true ? true :false, OccupationYear = occupationYear.Text, DisabledAccess = disabledAccesss.SelectedItem.ToString(), DisabledComment = disabledComment.Text, ConstructionDescription = constructionDescription.Text, GPSCoordinates = _GPSCoordinates, Photo = PhotoIsChanged == true ? FileName : building.Photo, CreatedDate = new DateTime(), CreatedUserId = userId, ModifiedUserId = userId, Facility = new Facility { Id = facilityId } }; bool isAdded = false; if (!isEdit) { isAdded = await ViewModel.AddBuildingAsync(item); } else { isAdded = await ViewModel.UpdateBuildingAsync(item); } if (isAdded) { if (PhotoIsChanged) { PictureViewModel pictureViewModel = new PictureViewModel(); Bitmap _bm = ((BitmapDrawable)buildingPhoto.Drawable).Bitmap; string bal = ""; if (_bm != null) { MemoryStream stream = new MemoryStream(); _bm.Compress(Bitmap.CompressFormat.Jpeg, 100, stream); byte[] ba = stream.ToArray(); bal = Base64.EncodeToString(ba, Base64.Default); } Models.Picture picture = new Models.Picture() { Name = FileName, File = bal, }; List <Models.Picture> pictures = new List <Models.Picture>(); pictures.Add(picture); await pictureViewModel.ExecuteSavePictureCommand(pictures); } messageDialog.HideLoading(); if (!isEdit) { messageDialog.SendToast("Building is added successful."); } else { messageDialog.SendToast("Building is updated successful."); } Finish(); } else { messageDialog.HideLoading(); if (!isEdit) { messageDialog.SendToast("Unable to add new building."); } else { messageDialog.SendToast("Unable to update building."); } } }