/// <summary> /// Save a new location data to the parse user. /// This method does not save the data to the server. /// Need to call SaveAsync on the user afterwards. /// </summary> /// <param name="user">the user whose location is to be saved</param> /// <param name="newData">the new location data</param> public static void SaveLocationToParseUser(ParseUser user, GeoPosition<GeoCoordinate> newData) { int lastLocationIndex = user.Get<int>(ParseContract.UserTable.LAST_LOCATION_INDEX); int newLocationIndex = lastLocationIndex + 1; newLocationIndex %= user.Get<int>(ParseContract.UserTable.LOCATION_DATA_SIZE); user[ParseContract.UserTable.LAST_LOCATION_INDEX] = newLocationIndex; if (!user.ContainsKey(ParseContract.UserTable.LOCATION(newLocationIndex)))//If the new slot was not filled. { user[ParseContract.UserTable.LOCATION(newLocationIndex)] = ParseContract.LocationTable.GeoPositionToParseObject(newData); } else//If the new slot contains a valid location { ParseObject newLocation = user.Get<ParseObject>(ParseContract.UserTable.LOCATION(newLocationIndex)); //Change the location entry without creating a new one. ParseContract.LocationTable.GeoPositionSetParseObject(newData, newLocation); } user[ParseContract.UserTable.LAST_GEO_POINT] = new ParseGeoPoint(newData.Location.Latitude, newData.Location.Longitude); }
public static bool ReadParseUser(ParseUser user) { if (user.ContainsKey("Created")) { if (user.ContainsKey("MaxScore")) { var maxscore = (long)user["MaxScore"]; _maxScore = (int)maxscore; } return true; } else { return false; } }