public async Task RemovePlaceFromCollectionAsync(Place place) { if (Places.Any(x => x.Id == place.Id)) { Places.Remove(place); await _settingsService.SavePlacesAsync(Places); } }
public void AddPlace(Place placeToAdd) { if (Places.Any(x => x.Id.Equals(placeToAdd.Id))) { throw new ArgumentException($"Id: {placeToAdd.Id} cannot be the same for two places"); } if (Places.Contains(placeToAdd)) { throw new ArgumentException($"You already add {placeToAdd}"); } Places.Add(placeToAdd); }
public static void AddPlace(Place place) { int id = 1; for (; Places.Any(i => i.Id == id); id++) { ; } SQLiteCommand cmd = new SQLiteCommand("insert into Places values (@id,@name,@desc,@group)", conn); cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@name", place.Name); cmd.Parameters.AddWithValue("@desc", place.Description); cmd.Parameters.AddWithValue("@group", place.Group); cmd.ExecuteNonQuery(); }
public int SavePlace(Place item) { item.OwnerServerId = ApplicationSettings.CurrentUser.Guid; if ( Places.Any( i => i.OwnerServerId == ApplicationSettings.CurrentUser.Guid && i.ServerId == item.ServerId)) { _db.Update(item); return(item.Id); } else { var a = _db.Insert(item); return(a); } //item.OwnerServerId = ApplicationSettings.CurrentUser.Guid; //if (item.Id == 0) return _db.Insert(item); //_db.Update(item); //return item.Id; }
/// <summary> /// All the geocoding data can be gotten from: http://download.geonames.org/export/dump/ /// </summary> /// <param name="input"></param> public void SetCountryInfos(Stream input) { CountryInfos.Clear(); using (StreamReader db = new StreamReader(input)) { string line; while (!db.EndOfStream && (line = db.ReadLine()) != null) { if (line.StartsWith("#")) { continue; } var countryInfo = new CountryInfo(line); CountryInfos.Add(countryInfo); } } if (Places.Any()) { Places.ForEach(p => p.Country = CountryInfos.Find(c => c.ISO == p.CountryCode)); } }
public bool ContainsPlace(CartoPlaceInfo place) { return(Places.Any(x => x.Key == place.Key)); }