public static async Task <IEnumerable <ShopSensorEvent> > GetTodayEvents() { var response = await http.GetAsync("api/ShopSensor?daysSince=1"); var content = await response.Content.ReadAsStringAsync(); return(ShopSensorEvent.FromJson(content)); }
public async Task <HttpResponseMessage> Post([FromBody] ShopSensorEvent newEvent) { await DocDBRepository <ShopSensorEvent> .CreateItemAsync(newEvent); var pushNotificationResponse = await PushNotificationService.TriggerPushNotification(newEvent.EventType, config.Notifications.HubName, config.Notifications.FullListener); HttpResponseMessage res = new HttpResponseMessage(HttpStatusCode.OK); return(res); }
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")); }
public async Task <IEnumerable <ShopSensorEvent> > ReadTodayEvents() { return(ShopSensorEvent.FromJson( await(await http.GetAsync("api/ShopSensor?DaysSince=2")) .Content.ReadAsStringAsync())); }