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."); } } }
void CancelButton_Click(object sender, EventArgs e) { 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>(); intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(facility)); this.StartActivity(intent); Finish(); }
void Adapter_ItemClick(object sender, RecyclerClickEventArgs e) { var item = ViewModel.Facilities[e.Position]; var intent = new Intent(Activity, typeof(FacilityDetailActivity)); //var intent = new Intent(Activity, typeof(FacilityInformationActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(item.Id.ToString()); item.Buildings = new List <Building>(); intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(item)); Activity.StartActivity(intent); }
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 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."); } } }