/// <summary> /// Gets selected vehicle. /// </summary> /// <returns>Return <see cref="null"/> if there are no info about selected vehicle, otherwise returns <see cref="ClientVehicleDto"/> object.</returns> public ClientVehicleDto GetSelectedVehicleId() { if (!_connectionService.IsConnected) { return(null); } var getMissionReq = new GetMissionPreferencesRequest() { User = _connectionService.GetUser(), ClientId = _connectionService.GetClientId(), Mission = null, }; var getMissionResp = _connectionService.Execute <GetMissionPreferencesResponse>(getMissionReq); MissionPreference pref = getMissionResp.Preferences.FirstOrDefault(p => p.Name == PREF_NAME); int?id = missionPreferenceToVehicleId(pref, getMissionReq.User.Id); if (id != null) { var v = getVehicleById(id.Value); if (v != null) { return(new ClientVehicleDto() { Name = v.Name, VehicleId = v.Id }); } } return(null); }
/// <summary> /// Return <see cref="null"/> if there are no info about selected vehicle /// </summary> /// <returns></returns> public string GetSelectedVehicleTailNumber() { if (!_connectionService.IsConnected) { return(null); } var getMissionReq = new GetMissionPreferencesRequest() { User = _connectionService.User, ClientId = _connectionService.ClientId, Mission = null, }; var getMissionResp = _connectionService.Execute <GetMissionPreferencesResponse>(getMissionReq); MissionPreference pref = getMissionResp.Preferences.Where(p => p.Name == PREF_NAME).FirstOrDefault(); int?id = missionPreferenceToVehicleId(pref, getMissionReq.User.Id); if (id != null) { return(getVehicleTailNumberById(id.Value)); } return(null); }