示例#1
0
        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);
        }
示例#3
0
        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"));
        }
示例#4
0
        /// <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"));
        }
示例#5
0
 public async Task <IEnumerable <ShopSensorEvent> > ReadTodayEvents()
 {
     return(ShopSensorEvent.FromJson(
                await(await http.GetAsync("api/ShopSensor?DaysSince=2"))
                .Content.ReadAsStringAsync()));
 }