public async Task <IActionResult> PutGpsTrace(string id, [FromBody] OsmTrace trace) { var gateway = _httpGatewayFactory.CreateOsmGateway(_cache.Get(User.Identity.Name)); await gateway.UpdateTrace(trace); return(Ok()); }
public async Task UpdateTrace(OsmTrace trace) { using (var client = new HttpClient()) { var traceAddress = _traceAddress.Replace(":id", trace.Id); UpdateHeaders(client, traceAddress, "PUT"); var osmRequest = new Osm { GpxFiles = new[] { new GpxFile { Name = trace.Name, Description = trace.Description, Visibility = trace.Visibility, Id = int.Parse(trace.Id), Lat = trace.LatLng.lat, Lon = trace.LatLng.lng, Tags = trace.Tags.ToArray() } } }; var response = await client.PutAsync(traceAddress, new StringContent(osmRequest.SerializeToXml())); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Unable to update OSM trace"); } } }