コード例 #1
0
 public PlaceViewModel(IShredderService service)
 {
     this.shredderService = service;
     LoadPlacesCommand = new RelayCommand(LoadPlaces);
     SavePlaceCommand = new RelayCommand(SavePlace);
     NewPlace = new Place();
 }
コード例 #2
0
 public Place AddPlace(Place place)
 {
     if (place.PlaceId == 0)
     {
         return this.context.Places.Add(place);
     }
     else
     {
         Place placeToUpdate = this.context.Places.Where(p => p.PlaceId == place.PlaceId).FirstOrDefault();
         if (placeToUpdate != null)
         {
             this.context.Entry(placeToUpdate).CurrentValues.SetValues(place);
         }
         return null;
     }   
 }
コード例 #3
0
 private void MakeNewSpot(object sender, TappedRoutedEventArgs e)
 {
     Place newPlace = new Place();
     newPlace.UserId = _vm.ActiveUser.UserId;
     newPlace.Longitude = myTappedLocation.Longitude;
     newPlace.Latitude = myTappedLocation.Latitude;
     newPlace.Name = txtNewSpotName.Text;
     newPlace.Description = txtDescription.Text;
     newPlace.Rating = 0;
     _vm.saveSpot(newPlace);
     NewPlaceLayOver.Visibility = Visibility.Collapsed;
 }
コード例 #4
0
 public async Task<Place> GetPlaceByLatitude(double lat)
 {
     Place place = new Place();
     using (HttpClient client = new HttpClient())
     {
         string url = string.Format("{0}{1}", URL, "/place?latitude=" + lat);
         using (HttpResponseMessage response = await client.GetAsync(url))
         {
             if (response.IsSuccessStatusCode)
             {
                 string content = await response.Content.ReadAsStringAsync();
                 place = await JsonConvert.DeserializeObjectAsync<Place>(content);
             }
         }
     }
     return place;
 }
コード例 #5
0
 //ADDPLACE & LIST OF PLACES
 public async void AddPlace(Place place)
 {
     using (HttpClient client = new HttpClient())
     {
         try
         {
             string url = string.Format("{0}{1}", URL, "place");
             string json = JsonConvert.SerializeObject(place);
             HttpContent content = new StringContent(json);
             content.Headers.Clear();
             content.Headers.Add("Content-Type", "application/json");
             await client.PostAsync(url, content);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
コード例 #6
0
 public void UpdateSpotRating(Place Place)
 {
     shredderService.AddPlace(Place);
 }
コード例 #7
0
 public void saveSpot(Place place)
 {
    shredderService.AddPlace(place);
 }
コード例 #8
0
 private void Button_Tap_2(object sender, System.Windows.Input.GestureEventArgs e)
 {
     Place newPlace = new Place();
     //newPlace.UserId = user.UserId;        NIET VERGETEN UIT COMMENTAAR TE ZETTEN
     newPlace.UserId = 4169;
     newPlace.Longitude = myTappedLocation.Longitude;
     newPlace.Latitude = myTappedLocation.Latitude;
     newPlace.Name = txtNewSpotName.Text;
     newPlace.Description = txtDescription.Text;
     newPlace.Rating = 0;
     _vm.saveSpot(newPlace);
     createSpot.Visibility = Visibility.Collapsed;
 }