private async void BtnAccept_Click(object sender, EventArgs e) { string token = SettingsHelper.GetToken(this); long requestId = Intent.GetLongExtra("requestId", 0); btnAccept.Visibility = ViewStates.Invisible; progressBar.Visibility = ViewStates.Visible; if (appState == AppState.Idle) { RequestVM request = await ServiceHelper.AcceptRequest(token, requestId); if (request != null) { appState = AppState.Arriving; btnAccept.SetText(Resource.String.start_treatment); //btnAccept.Visibility = ViewStates.Gone; btnCall.Visibility = ViewStates.Visible; btnNavigate.Visibility = ViewStates.Visible; await Repository.SaveRequest(request); tvHint.Text = "YOU ARE NOW TRAVELLING TO THE PATIENT'S LOCATION"; tvDurationTitle.Visibility = ViewStates.Visible; tvDuration.Visibility = ViewStates.Visible; initialTime = DateTime.Now; timer = new Timer(1000); timer.Elapsed += Timer_Elapsed; timer.Start(); } } else if (appState == AppState.Arriving) { RequestVM request = await ServiceHelper.AdministerRequest(token, requestId); if (request != null) { appState = AppState.ProvidingTreatment; btnAccept.SetText(Resource.String.finish); //btnNavigate.Visibility = ViewStates.Gone; //btnCall.Visibility = ViewStates.Gone; await Repository.SaveRequest(request); tvHint.Text = "YOU ARE NOW ADMINISTERING TREATMENT TO THE PATIENT"; initialTime = DateTime.Now; tvDurationTitle.Text = "TREATMENT DURATION"; } } else if (appState == AppState.ProvidingTreatment) { RequestVM request = await ServiceHelper.CompleteRequest(token, requestId); if (request != null) { appState = AppState.Completed; await Repository.SaveRequest(request); timer.Stop(); Intent intent = new Intent(this, typeof(InvoiceActivity)); intent.AddFlags(ActivityFlags.ClearTop); intent.PutExtra("request", JsonConvert.SerializeObject(request)); StartActivity(intent); Finish(); } } btnAccept.Visibility = ViewStates.Visible; progressBar.Visibility = ViewStates.Invisible; }