Ejemplo n.º 1
0
        public override async Task Init()
        {
            FeedbackTypeList = (await DataRetrievalService.GetAllFeedbackTypes()).ToObservableCollection();
            VehicleList      = (await DataRetrievalService.GetAllVehicles()).ToObservableCollection();

            if (FeedbackTypeList.Any())
            {
                SelectedFeedbackType = FeedbackTypeList[0];
            }

            //SelectedVehicle = VehicleList[0];

            //use this opportunity to grab the long/lat.
            var request          = new GeolocationRequest(GeolocationAccuracy.Medium);
            var locationRealtime = await Geolocation.GetLocationAsync(request);

            location = (locationRealtime == null) ? await Geolocation.GetLastKnownLocationAsync() : locationRealtime;
        }
        public async Task LoadData()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                if (base.IsConnected || App.UseSampleDataStore)
                {
                    //load SQLite from API or sample data
                    var count = await DataLoader.LoadFeedbackTypesAsync();

                    Debug.WriteLine($"Loaded {count} Feedback Types.");
                }

                //clear local list
                FeedbackTypeList.Clear();

                //populate local list
                var items = await DataStore.GetFeedbackTypesAsync();

                foreach (var item in items)
                {
                    FeedbackTypeList.Add(item);
                }

                SelectedFeedbackType = FeedbackTypeList.Where(z => z.Code == "GENERAL").FirstOrDefault();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.StackTrace);
                Crashes.TrackError(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }