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."); } }
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."); } } }