public bool DeleteLoc(FishingLoc loc) { FishingLoc.Delete(loc); HomeViewModel.UpdateLocs(); return(true); }
public async Task <bool> InsertLoc(FishingLoc loc, bool fromFish = false) { if (loc == null) { loc = new FishingLoc(); } Coordinate coor = new Coordinate() { IdCoordinate = Guid.NewGuid().ToString() }; if (LocActivationSwitchState) { //From geolocator try { var locator = CrossGeolocator.Current; var position = await locator.GetPositionAsync(); if (position != null) { coor.Lattitude = position.Latitude; coor.Longitude = position.Longitude; } } catch (Exception ex) { } } else { //from Selection loc.Name = CurrentLoc.Name; loc.PlaceCount = CurrentLoc.PlaceCount; loc.Type = CurrentLoc.Type; if (CreatedPins.Count == 1) { foreach (var pin in CreatedPins) { coor.Lattitude = pin.Pin.Position.Latitude; coor.Longitude = pin.Pin.Position.Longitude; } } } Waypoint wp = new Waypoint() { Coordinate = coor, IdWaypoint = Guid.NewGuid().ToString() }; loc.Waypoints.Add(wp); if (fromFish) { loc.Type = "GPS"; loc.Name = null; loc.PlaceCount = 0; } else { loc.Type = CurrentLoc.Type; loc.Name = CurrentLoc.Name; loc.PlaceCount = CurrentLoc.PlaceCount; } loc.IdFishingLoc = Guid.NewGuid().ToString(); loc.User_IdUser = App.user.IdUser; FishingLoc.Insert(loc); CurrentLoc = new FishingLoc(); CreatedPins.Clear(); HomeViewModel.UpdateLocs(); return(true); }