/// <summary> /// Locks a bikestand and updates the interface /// </summary> private void Lock() { BikeStandRegistration bikestandRegistration = null; if (int.TryParse(LockID, out int convertedLockID)) { bikestandRegistration = serverClient.Lock(convertedLockID); } else { IsLockErrorVisible = true; } if (bikestandRegistration != null) { BikeStation bikeStation = serverClient.GetBikeStation("" + bikestandRegistration.BikeStandID); IsAddFriendEnabled = true; IsLockIDEnabled = false; LockVisible = false; UnlockVisible = true; IsLockErrorVisible = false; IsAddFriendVisible = true; BikeStationText = String.Format("Your bike was locked at {0} on the {1}", bikeStation.title, bikestandRegistration.RegistrationTime); IsBikeStationVisible = true; } else { IsLockErrorVisible = true; } }
/// <summary> /// This method updates the interface according to the relevant data from the backend when the Actionview appears /// </summary> public void OnAppearing() { if (sharedData.ScannedBikestandID != null) { int qrLockID; if (int.TryParse(sharedData.ScannedBikestandID, out qrLockID)) { LockID = "" + qrLockID; } } sharedData.ScannedBikestandID = null; BikeStandRegistration bikestandRegistration = serverClient.GetLockedBikestand(); if (bikestandRegistration != null) { LockID = "" + bikestandRegistration.BikeStandID; LockVisible = false; UnlockVisible = true; IsLockIDEnabled = false; IsAddFriendEnabled = true; IsAddFriendVisible = true; BikeStation bikeStation = serverClient.GetBikeStation("" + bikestandRegistration.BikeStandID); if (bikeStation != null) { BikeStationText = String.Format("Your bike was locked at {0} on the {1}", bikeStation.title, bikestandRegistration.RegistrationTime); IsBikeStationVisible = true; } String sharedWithUsername = serverClient.GetSharedUsername(); if (!String.IsNullOrEmpty(sharedWithUsername)) { sharedAccessTo = sharedWithUsername; SharedWithText = "Shared with: " + sharedAccessTo; IsShared = true; IsAddFriendEnabled = false; } } else { IsAddFriendVisible = false; IsBikeStationVisible = false; IsShared = false; IsAddFriendEnabled = true; } }