public static List <Core.Data.UserWaypoint> ImportUserWaypoints(Core.Storage.Database db, LiveV6.UserWaypoint[] wps, string GeocacheCode) { List <Core.Data.UserWaypoint> result = new List <Core.Data.UserWaypoint>(); List <Core.Data.UserWaypoint> curUwps = Utils.DataAccess.GetUserWaypointsFromGeocache(db, GeocacheCode); if (wps != null) { foreach (var lg in wps) { Core.Data.UserWaypoint g = ImportUserWaypoint(db, lg); if (g != null) { result.Add(g); if (curUwps.Contains(g)) { curUwps.Remove(g); } } } } foreach (var g in curUwps) { g.DeleteRecord(); db.UserWaypointCollection.Remove(g); } return(result); }
public static Core.Data.UserWaypoint ImportUserWaypoint(Core.Storage.Database db, LiveV6.UserWaypoint wp) { Core.Data.UserWaypoint result = null; if (wp != null) { result = db.UserWaypointCollection.GetUserWaypoint(wp.ID.ToString()); Core.Data.IUserWaypointData wpd; if (result == null) { wpd = new Core.Data.UserWaypointData(); wpd.ID = wp.ID.ToString(); } else { wpd = result; } wpd.Description = wp.Description; wpd.GeocacheCode = wp.CacheCode; wpd.Lat = wp.Latitude; wpd.Lon = wp.Longitude; wpd.Date = wp.UTCDate.ToLocalTime(); if (wpd is Core.Data.UserWaypointData) { if (Utils.DataAccess.AddUserWaypoint(db, wpd as Core.Data.UserWaypointData)) { result = db.UserWaypointCollection.GetUserWaypoint(wp.ID.ToString()); if (wp.IsCorrectedCoordinate) { Core.Data.Geocache thisGC = db.GeocacheCollection.GetGeocache(wp.CacheCode); if (thisGC != null) { thisGC.CustomLat = wp.Latitude; thisGC.CustomLon = wp.Longitude; } } } } } return(result); }