private async Task ExecuteSetNextState(NextStateActionOfIncident action) { string confirmationMessage; if (_viewModel.IncidentItem?.Type == GeoIncidentType.Relocation && action.PlannedState == OneTimeActionTaskState.AAO) { confirmationMessage = "Soll der Status auf 'Standort halten am Zielort' gesetzt werden?"; } else if (action.PlannedState == OneTimeActionTaskState.DETACHED) { confirmationMessage = "Soll der Einsatz beendet werden?"; } else { confirmationMessage = $"Soll der Status der Einheit auf '{action.PlannedState}' geändert werden?"; } bool confirmed = await DisplayAlert("Status setzen", confirmationMessage, "Ja", "Nein"); if (confirmed) { await Navigation.PushAsync(new StatusSendingModalPage()); await _httpClient.PostAsync(action.Url, new StringContent("")).ContinueWith(actionResponse => { var resultCode = NextStateActionResultCode.OPERATION_FAILED; try { resultCode = GetResultCodeOfOperation(actionResponse); } catch (Exception e) { Console.WriteLine("Failed to parse one-time-action response from server!"); Console.WriteLine(e.ToString()); } ReportFinishedStateChange(resultCode, action.PlannedState); }); } }
private static NextStateActionOfIncident CreateNextStateAction(JObject actionJsonObject) { NextStateActionOfIncident createdAction = null; try { Uri parsedUrl = new Uri(actionJsonObject.Value <string>(GeobrokerActionConstants.urlProperty)); OneTimeActionTaskState parsedPlannedState = (OneTimeActionTaskState)Enum.Parse(typeof(OneTimeActionTaskState), actionJsonObject.Value <string>(GeobrokerActionConstants.additionalDataProperty)); createdAction = new NextStateActionOfIncident(parsedUrl, parsedPlannedState); } catch (ArgumentException e) { Console.WriteLine("Failed to build one-time-action from received JSON."); Console.WriteLine(e.ToString()); } catch (UriFormatException e) { Console.WriteLine("Failed to create URL of one-time-action."); Console.WriteLine(e.ToString()); } return(createdAction); }