private async void ButtonMarkClick(object sender, RoutedEventArgs e) { await _mapLocationAccess.Add( DataSourceType.Sqlite, new MapLocationModel { ID = Guid.NewGuid(), Name = _focusedMapPin.Name, Description = _focusedMapPin.Description, Latitude = _focusedMapPin.Latitude.ToString(), Longitude = _focusedMapPin.Longitude.ToString(), MapId = _map.ID }); MapLocationModel addedLocation = _mapLocations.FirstOrDefault(location => location.Latitude == _focusedMapPin.Latitude.ToString() && location.Longitude == location.Longitude); if (addedLocation != null) { _focusedMapPin.ID = addedLocation.ID; } _mapPins.Add(_focusedMapPin); _focusedMapPin.Mark(); _mapLocationFolderAccess.MapLocationId = addedLocation.ID; _mapLocationFolders = await _mapLocationFolderAccess.GetSources(DataSourceType.Sqlite); DefaultViewModel["MapLocationFolders"] = _mapLocationFolders; DefaultViewModel["Linkable"] = (bool)DefaultViewModel["Focused"] && _focusedMapPin.Marked; DefaultViewModel["Markable"] = (bool)DefaultViewModel["Focused"] && !(bool)DefaultViewModel["Linkable"]; DefaultViewModel["UnMarkable"] = (bool)DefaultViewModel["Linkable"]; }
private async void MapPinElementMapPinTapped(object sender, MapPinTappedEventArgs e) { MapPin mapPinElement = (MapPin)sender; if (mapPinElement.Focused) { if (e.Marked) { await _mapLocationAccess.Add( DataSourceType.Sqlite, new MapLocationModel { ID = Guid.NewGuid(), Name = mapPinElement.Name, Description = mapPinElement.Description, Latitude = mapPinElement.Latitude.ToString(), Longitude = mapPinElement.Longitude.ToString(), MapId = _map.ID }); MapLocationModel addedLocation = _mapLocations.FirstOrDefault(location => location.Latitude == mapPinElement.Latitude.ToString() && location.Longitude == location.Longitude); if (addedLocation != null) { mapPinElement.ID = addedLocation.ID; } _mapPins.Add(mapPinElement); } else { MapLocationModel deleteLocation = _mapLocations.FirstOrDefault(location => location.ID.Equals(mapPinElement.ID)); if (deleteLocation != null) { await _mapLocationAccess.Remove(DataSourceType.Sqlite, deleteLocation); } _mapPins.Remove(mapPinElement); } } _lastFocusedMapPin = _focusedMapPin; _focusedMapPin = mapPinElement; if (_lastFocusedMapPin != null) { _lastFocusedMapPin.UnFocus(); } if (!_focusedMapPin.Focused) { _focusedMapPin.Focus(); } }
public Task RemoveLocation(MapLocationModel mapLocation) { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString); _locations.Remove(mapLocation); connection.ExecuteAsync("DELETE FROM MapLocationFolders WHERE MapLocationId = ?", mapLocation.ID); return(connection.DeleteAsync(mapLocation)); }
public Task UpdateLocation(MapLocationModel mapLocation) { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString); _locations.Remove(_locations.First(location => location.ID == mapLocation.ID)); _locations.Add(mapLocation); return(connection.UpdateAsync(mapLocation)); }
public async Task<int> AddLocation(MapLocationModel mapLocation, Guid mapId) { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString); int count = await connection.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM MapLocations WHERE MapId = ? AND Latitude = ? AND Longitude = ?", mapId, mapLocation.Latitude, mapLocation.Longitude); if (count > 0) return 0; mapLocation.MapId = mapId; _locations.Add(mapLocation); return await connection.InsertAsync(mapLocation); }
private async void ButtonUnMarkClick(object sender, RoutedEventArgs e) { MapLocationModel deleteLocation = _mapLocations.FirstOrDefault(location => location.ID.Equals(_focusedMapPin.ID)); if (deleteLocation != null) { await _mapLocationAccess.Remove(DataSourceType.Sqlite, deleteLocation); } _mapPins.Remove(_focusedMapPin); _focusedMapPin.UnMark(); DefaultViewModel["Linkable"] = (bool)DefaultViewModel["Focused"] && _focusedMapPin.Marked; DefaultViewModel["Markable"] = (bool)DefaultViewModel["Focused"] && !(bool)DefaultViewModel["Linkable"]; DefaultViewModel["UnMarkable"] = (bool)DefaultViewModel["Linkable"]; }
public async Task <int> AddLocation(MapLocationModel mapLocation, Guid mapId) { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString); int count = await connection.ExecuteScalarAsync <int>("SELECT COUNT(*) FROM MapLocations WHERE MapId = ? AND Latitude = ? AND Longitude = ?", mapId, mapLocation.Latitude, mapLocation.Longitude); if (count > 0) { return(0); } mapLocation.MapId = mapId; _locations.Add(mapLocation); return(await connection.InsertAsync(mapLocation)); }
public Task UpdateLocation(MapLocationModel mapLocation) { throw new NotImplementedException(); }
public Task<int> AddLocation(MapLocationModel mapLocation, Guid mapId) { throw new NotImplementedException(); }
public Task RemoveLocation(MapLocationModel mapLocation) { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString); _locations.Remove(mapLocation); connection.ExecuteAsync("DELETE FROM MapLocationFolders WHERE MapLocationId = ?", mapLocation.ID); return connection.DeleteAsync(mapLocation); }
public Task UpdateLocation(MapLocationModel mapLocation) { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString); _locations.Remove(_locations.First(location => location.ID == mapLocation.ID)); _locations.Add(mapLocation); return connection.UpdateAsync(mapLocation); }
public Task UpdateLocation(MapLocationModel mapLocation) { throw new NotImplementedException(); }
public Task <int> AddLocation(MapLocationModel mapLocation, Guid mapId) { throw new NotImplementedException(); }