private async void LoadData() { var list = await apiService.GetAllGeolocation(); Geolocations.Clear(); foreach (var item in list) { Geolocations.Add(new GeolocationViewModel() { Title = item.Title, Description = item.Description, Latitud = item.Latitud, Longitud = item.Longitud, FechaCreacion = item.FechaCreacion, BrowseCommand = new Command <GeolocationViewModel>(GeoBinding) }); } //,FechaCreacion = item.FechaCreacion //Geolocations = new ObservableCollection<GeolocationViewModel>(); //for (int i = 0; i < 4; i++) //{ // Geolocations.Add(new GeolocationViewModel() // { // Title = "Sevilla", // Description = "Espana", // CreationDate = DateTime.Today, // Latitud = "Lat 1", // Longitud = "Long 2" // }); //} }
public async Task <Geolocations> CreateGeolocation(Geolocations newGeolocations) { using (HttpClient client = new HttpClient()) { string url = "http://apirestproyectoxam.azurewebsites.net/tables/Geolocation"; client.DefaultRequestHeaders.Add("ZUMO-API-VERSION", "2.0.0"); string content = JsonConvert.SerializeObject(newGeolocations); StringContent body = new StringContent(content, Encoding.UTF8, "application/json"); var result = await client.PostAsync(url, body); string data = await result.Content.ReadAsStringAsync(); if (result.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <Geolocations>(data)); } else { return(null); } } }
public void SaveGPSLocationData(string token, string longitude, string latitude) { Geolocations geolocations = new Geolocations(); geolocations.Latitude = latitude; geolocations.Longitude = longitude; sqlCoommandTaxiApi.SaveGPSLocationData(token, geolocations); }
internal async void SaveGPSLocationData(string token, Geolocations geolocations) { Driver driver = context.Drivers.Where(d => d.Token == token) .Include(d => d.geolocations) .FirstOrDefault(); driver.geolocations = geolocations; await context.SaveChangesAsync(); }