public static Core.Data.Waypoint ImportWaypoint(Core.Storage.Database db, LiveV6.AdditionalWaypoint wp) { Core.Data.Waypoint result = null; if (wp != null) { result = db.WaypointCollection.GetWaypoint(wp.Code); Core.Data.IWaypointData wpd; if (result == null) { wpd = new Core.Data.WaypointData(); wpd.Code = wp.Code; wpd.ID = wp.Code; } else { wpd = result; } wpd.DataFromDate = DateTime.Now; wpd.WPType = Utils.DataAccess.GetWaypointType(wp.WptTypeID); wpd.Comment = wp.Comment; wpd.Description = wp.Description; wpd.GeocacheCode = wp.GeocacheCode; wpd.Lat = wp.Latitude; wpd.Lon = wp.Longitude; wpd.Name = wp.Name; wpd.Time = wp.UTCEnteredDate; wpd.Url = wp.Url; wpd.UrlName = wp.UrlName; if (wpd is Core.Data.WaypointData) { if (Utils.DataAccess.AddWaypoint(db, wpd as Core.Data.WaypointData)) { result = db.WaypointCollection.GetWaypoint(wp.Code); } } } return(result); }
public static Framework.Data.Waypoint Waypoint(Framework.Interfaces.ICore core, LiveV6.AdditionalWaypoint wp) { Framework.Data.Waypoint result = null; if (wp != null) { Framework.Data.Waypoint tmp = DataAccess.GetWaypoint(core.Waypoints, wp.Code); result = new Framework.Data.Waypoint(); if (tmp != null) { result.UpdateFrom(tmp); } result.Code = wp.Code; result.DataFromDate = DateTime.Now; result.WPType = DataAccess.GetWaypointType(core.WaypointTypes, wp.WptTypeID); result.Comment = wp.Comment; result.Description = wp.Description; result.GeocacheCode = wp.GeocacheCode; result.ID = wp.Code; result.Lat = wp.Latitude; result.Lon = wp.Longitude; result.Name = wp.Name; result.Time = wp.UTCEnteredDate; result.Url = wp.Url; result.UrlName = wp.UrlName; } return(result); }