示例#1
0
        /// <summary>
        /// Sets the location and saves it to the database.
        /// </summary>
        /// <param name="location">Location.</param>
        private void SetLocation(Location location)
        {
            var currentLocation = location;

            if (currentLocation == null)
            {
                //Retrieve saved location from database

                LocationDTO stored_location = db_helper.GetSavedLocation();
                Latitude  = stored_location.Latitude;
                Longitude = stored_location.Longitude;
            }
            else
            {
                //Set newly updated location strings, and update database with new location.

                Latitude  = currentLocation.Latitude.ToString();
                Longitude = currentLocation.Longitude.ToString();

                LocationDTO new_location = new LocationDTO();
                new_location.Latitude  = Latitude;
                new_location.Longitude = Longitude;

                db_helper.SaveLocation(new_location);
            }
        }
示例#2
0
 public void SaveLocation(LocationDTO locationDTO)
 {
     //Check if the table is not empty.
     if (sqLiteConnection.Query <LocationDTO>("SELECT * FROM Location").Count > 0)
     {
         //Retrieve the first row entry. This entry will be updated with the latest location.
         var item = sqLiteConnection.Get <LocationDTO>(1);
         item.Latitude  = locationDTO.Latitude;
         item.Longitude = locationDTO.Longitude;
         sqLiteConnection.Update(item);
     }
     else
     {
         //Add a new entry if the table is empty.
         sqLiteConnection.Insert(locationDTO);
     }
 }