Пример #1
0
        public async Task <bool> SaveRouteAsync(Route route)
        {
            bool IsSuccesful = true;
            //If the name is used, disregard
            List <int> IsTaken = await Database.QueryAsync <int>("SELECT RouteID FROM DatabaseRoute WHERE Name = ?", new object[] { route.Name });

            if (IsTaken.Count != 0)
            {
                return(false); //IsSuccesful = false;
            }
            //Otherwise insert it.
            DatabaseRoute forDatabase = DatabaseRoute.ToDatabaseRoute(route);
            await Database.InsertAsync(forDatabase);

            foreach (Waypoint w in route.WayPoints)
            {
                int existingID = await Database.ExecuteScalarAsync <int>("SELECT WaypointID FROM DatabasePOI WHERE Latitude = ? AND Longitude = ?", new object[] { w.Latitude, w.Longitude });

                if (existingID == 0)
                {
                    int waypointID = await SaveWaypoint(w);

                    await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, waypointID });
                }
                else
                {
                    await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, existingID });
                }
            }
            return(IsSuccesful);
        }
Пример #2
0
        public async Task <bool> SaveVisitedRouteAsync(Route route)
        {
            bool          IsSuccesful = true;
            DatabaseRoute forDatabase = DatabaseRoute.ToDatabaseRoute(route);

            forDatabase.Name = "FWGFETY^Rufw4r6ue6fyue46YGE^GU#EÛE6gue6guef6ug6eg6gue46gue6EU^GUE^FUEG%Ê";
            await DeleteVisitedRoute();

            forDatabase.RouteID = 998; //Set to reserved ID
            await Database.InsertAsync(forDatabase);

            foreach (Waypoint w in route.WayPoints)
            {
                int existingID = await Database.ExecuteScalarAsync <int>("SELECT WaypointID FROM DatabasePOI WHERE Latitude = ? AND Longitude = ?", new object[] { w.Latitude, w.Longitude });

                await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, existingID });
            }
            return(IsSuccesful);
        }
Пример #3
0
        public async Task <bool> SaveCurrentRouteAsync(Route route)
        {
            bool          IsSuccesful = true;
            DatabaseRoute forDatabase = DatabaseRoute.ToDatabaseRoute(route);

            forDatabase.Name = "DF%Yyw54ye54yfw5u6ujtrhjw6hw45w4%HW$%HWT$GFWt4hft4th4wvhwtrg";
            await DeleteCurrentRoute();

            forDatabase.RouteID = 999; //Set to reserved ID
            await Database.InsertAsync(forDatabase);

            foreach (Waypoint w in route.WayPoints)
            {
                int existingID = await Database.ExecuteScalarAsync <int>("SELECT WaypointID FROM DatabasePOI WHERE Latitude = ? AND Longitude = ?", new object[] { w.Latitude, w.Longitude });

                await Database.ExecuteAsync("INSERT INTO RouteBinds VALUES(?, ?)", new object[] { forDatabase.RouteID, existingID });
            }
            return(IsSuccesful);
        }