private async void newtrip_bob(Trip data) { if (data != null || MainViewVM.CurrentTrip == null) { VindRitBobVM.Request = 1; this.BobRequests = "Momenteel " + VindRitBobVM.Request.ToString() + " aanvragen"; await UserRepository.PostPoint(); this.IsEnabledOffer = false; this.VisibleCancel = Visibility.Visible; this.VisibleOffer = Visibility.Visible; MainViewVM.CurrentTrip = data; SetStatus(data.StatusID.Value); Location location = await LocationService.GetCurrent(); Party party = Task.FromResult<Party>(await PartyRepository.GetPartyById(MainViewVM.CurrentTrip.Party_ID)).Result; Users_Destinations destination = Task.FromResult<Users_Destinations>(await DestinationRepository.GetDestinationById(MainViewVM.CurrentTrip.Destinations_ID)).Result; VindRitFilterVM.SelectedDestination = destination; this.SelectedParty = party; Response farEnough = Task.FromResult<Response>(await TripRepository.Difference((Location)this.SelectedParty.Location, location)).Result; if (farEnough.Value != null) { if (double.Parse(farEnough.Value.ToString()) < 600) { //bij het feestje ShowRoute((Location)party.Location, (Location)destination.Location); SetStatus(8); ToDestination = true; } else { ShowRoute(location, (Location)party.Location); ToDestination = false; } } trip_location(); //trip.all invullen if (MainViewVM.CurrentTrip != null) { Trip.All trips_all = new Trip.All(); User.All user = await UsersRepository.GetUserById(MainViewVM.CurrentTrip.Users_ID); Bob.All bob = await BobsRepository.GetBobById(MainViewVM.CurrentTrip.Bobs_ID); Trip.All newTrip = new Trip.All(); newTrip.Trip = MainViewVM.CurrentTrip; newTrip.Party = party; newTrip.User = user; newTrip.Bob = bob; newTrip.Destination = destination; this.CurrentTrip = newTrip; } RaiseAll(); } }
public static async Task<Response> PostParty(Party party) { try { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(URL.BASE); var newObject = JsonConvert.SerializeObject(party); HttpResponseMessage result = await client.PostAsync(URL.PARTIES, new StringContent(newObject, Encoding.UTF8, "application/json")); string json = await result.Content.ReadAsStringAsync(); Response data = JsonConvert.DeserializeObject<Response>(json); return data; } } catch (JsonException jex) { return new Response() { Error = "Parse Error: " + jex.ToString(), Success = false }; } catch (Exception ex) { return new Response() { Error = ex.Message.ToString(), Success = false }; } }