public async Task CreateEvent(bool eventType) { var newEvent = new ShopSensorEvent { EventType = eventType, EventTime = DateTime.Now.AddDays(-2) }; var json = newEvent.ToJson(); HttpResponseMessage message = await http .PostAsync("api/ShopSensor", new StringContent(json, Encoding.UTF8, "application/json")); }
/// <summary> /// Used to update the IoT UI (for debugging) and send a message to the web API /// </summary> private async void CreateEvent(bool eventType) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => GpioStatus.Text = eventType.ToString()); var newEvent = new ShopSensorEvent { EventType = eventType, EventTime = DateTime.Now }; HttpClient http = new HttpClient();// { BaseAddress = new Uri(baseuri) }; HttpResponseMessage message = await http .PostAsync(new Uri(baseuri + "/api/ShopSensor"), new HttpStringContent(newEvent.ToJson(), Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json")); }