Пример #1
0
        public void DeletePOI()
        {
            PointOfInterest testPOI = new PointOfInterest();
              testPOI.Name = "Delete POI";
              testPOI.Description = "POI being saved so we can test delete";
              testPOI.Address = "100 Main Street\nAnywhere, TX 75069";
              _poiService.SavePOI(testPOI);

              //Get id from New Created POI
              int testId = testPOI.Id.Value;

              // refresh the cashe to be sure the data was
              // poi was saved appropriately
              _poiService.RefreshCache();

              //Delete POI
              PointOfInterest deletePOI = _poiService.GetPOI(testId);
              Assert.IsNotNull(deletePOI);
              _poiService.DeletePOI(deletePOI);

              // refresh the cashe to be sure the data was
              // deleted appropriately
              _poiService.RefreshCache();

              PointOfInterest findPOI = _poiService.GetPOI(testId);
              Assert.Null(findPOI);
        }
Пример #2
0
        public void SavePOI(PointOfInterest poi)
        {
            Boolean newPOI = false;
              if (!poi.Id.HasValue)
              {
            poi.Id = GetNextId();
            newPOI = true;
              }

              // serialize POI
              string poiString = JsonConvert.SerializeObject(poi);
              // write new file or overwrite existing file
              File.WriteAllText(GetFilename(poi.Id.Value), poiString);

              // update cache if file save was successful
              // Note that we only need to add a POI to the cache when creating a new one and only after successfully writing the file.
              if (newPOI) _pois.Add(poi);
        }
Пример #3
0
        public void CreatePOI()
        {
            PointOfInterest newPOI = new PointOfInterest();
              newPOI.Name = "New POI";
              newPOI.Description = "POI to test creating a new POI";
              newPOI.Address = "100 Main Street\nAnywhere, TX 75069";
              _poiService.SavePOI(newPOI);

              //Get id from New Created POI
              int testId = newPOI.Id.Value;

              // refresh the cashe to be sure the data was saved appropriately
              _poiService.RefreshCache();

              // verify the newly create POI exists, get it from poiId
              PointOfInterest poi = _poiService.GetPOI(testId);
              Assert.NotNull(poi);
              Assert.AreEqual(poi.Name, "New POI");
        }
Пример #4
0
        public PointOfInterest GetPOI(int id)
        {
            PointOfInterest poi = _pois.Find(p => p.Id == id);

            return(poi);
        }
Пример #5
0
 public void DeletePOI(PointOfInterest poi)
 {
     File.Delete(GetFilename((int)poi.Id));
     _pois.Remove(poi);
 }
Пример #6
0
 public void DeletePOI(PointOfInterest poi)
 {
     File.Delete(GetFilename(poi.Id.Value));
       _pois.Remove(poi);
 }
Пример #7
0
        //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //LifeCycle
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

              SetContentView(Resource.Layout.POIDetail);

              // Get LocationManager Reference
              _locMgr = GetSystemService(Context.LocationService) as LocationManager;

              // Bind private variables to user interface widget
              _nameEditText = FindViewById<EditText>(Resource.Id.nameEditText);
              _descrEditText = FindViewById<EditText>(Resource.Id.descrEditText);
              _addrEditText = FindViewById<EditText>(Resource.Id.addrEditText);
              _latEditText = FindViewById<EditText>(Resource.Id.latEditText);
              _longEditText = FindViewById<EditText>(Resource.Id.longEditText);
              _poiImageView = FindViewById<ImageView>(Resource.Id.poiImageView);
              _locationImageButton = FindViewById<ImageButton>(Resource.Id.locationImageButton);
              _mapImageButton = FindViewById<ImageButton>(Resource.Id.mapImageButton);
              _photoImageButton = FindViewById<ImageButton>(Resource.Id.photoImageButton);

              // Event Handlers
              _locationImageButton.Click += GetLocationClicked;
              _mapImageButton.Click += MapClicked;
              _photoImageButton.Click += NewPhotoClicked;

              // Private declarations PointOfInterest _poi;
              if (Intent.HasExtra("poiId"))
              {
            int poiId = Intent.GetIntExtra("poiId", -1);
            // Get Poi Details from Service
            _poi = POIData.Service.GetPOI(poiId);
            Log.Info(GlobalApp.TAG, String.Format("Update _poi.Id[{0}], _poi.Name[{1}]", _poi.Id, _poi.Name));
              }
              else
              {
            // Create a New Poi
            _poi = new PointOfInterest();
            Log.Info(GlobalApp.TAG, "Create a New POI");
              }

              // Updates User Interface Widgets with POI Data
              UpdateUI();
        }