public PlaceViewModel(IShredderService service) { this.shredderService = service; LoadPlacesCommand = new RelayCommand(LoadPlaces); SavePlaceCommand = new RelayCommand(SavePlace); NewPlace = new Place(); }
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; } }
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; }
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; }
//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; } } }
public void UpdateSpotRating(Place Place) { shredderService.AddPlace(Place); }
public void saveSpot(Place place) { shredderService.AddPlace(place); }
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; }