Example #1
0
        protected override void OnResume()
        {
            SensorDataAccess dataAccess = new SensorDataAccess();

            dataAccess.sensors = sensors;
            dataAccess.GetSensors(Settings.LoginToken);
        }
Example #2
0
        private async Task FindUser(string user, string password)
        {
            String userUrl = string.Format(IHerokuService.LOGIN_URL);

            Uri uri = new Uri(userUrl);

            HttpClient client = new HttpClient();

            var requestContent = new Dictionary <string, string>();

            requestContent.Add("email", user);
            requestContent.Add("password", password);

            var response = await client.PostAsync(uri, new FormUrlEncodedContent(requestContent));

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                User userFound = Newtonsoft.Json.JsonConvert.DeserializeObject <User>(content);

                Settings.LoginToken = userFound._Id;

                ObservableCollection <Sensor> ob = new ObservableCollection <Sensor>();
                sensorsData.sensors = ob;

                sensorsData.GetSensors(userFound._Id);

                App.sensors = ob;

                redirectToDashboard();

                return;
            }

            imgLoading.IsVisible = false;
            btnLogin.IsEnabled   = true;

            await DisplayAlert("Error", "Could not find the requested user", "OK");
        }