Ejemplo n.º 1
0
 public static Framework.Data.UserWaypoint UserWaypoint(Framework.Interfaces.ICore core, LiveV6.UserWaypoint wp)
 {
     Framework.Data.UserWaypoint result = null;
     if (wp != null)
     {
         Framework.Data.UserWaypoint tmp = DataAccess.GetUserWaypoint(core.UserWaypoints, (int)wp.ID);
         result = new Framework.Data.UserWaypoint();
         if (tmp != null)
         {
             result.UpdateFrom(tmp);
         }
         result.Description  = wp.Description;
         result.GeocacheCode = wp.CacheCode;
         result.ID           = (int)wp.ID;
         result.Lat          = wp.Latitude;
         result.Lon          = wp.Longitude;
         result.Date         = wp.UTCDate.ToLocalTime();
     }
     return(result);
 }
Ejemplo n.º 2
0
        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);
        }