private async Task FetchSampleItemsAsync()
        {
            ListRefreshing = true;

            try
            {
                FetchModelCollectionResult <SampleItem> fetchResult = await _repository.FetchSampleItemsAsync();

                if (fetchResult.IsValid())
                {
                    SampleItems = fetchResult.ModelCollection.AsObservableCollection();

                    ListRefreshing = false;
                }
                else
                {
                    ListRefreshing = false;
                    await CC.UserNotifier.ShowMessageAsync(fetchResult.Notification.ToString(), "Fetch Sample Items Failed");
                }
            }
            finally
            {
                ListRefreshing = false;
            }
        }
예제 #2
0
        public async Task <FetchModelCollectionResult <Contact> > FetchContactsAsync()
        {
            FetchModelCollectionResult <Contact> retResult = new FetchModelCollectionResult <Contact>();
            var items = await _database.Table <Contact>().ToListAsync();

            retResult.ModelCollection = items;
            return(retResult);
        }
예제 #3
0
        public async Task <FetchModelCollectionResult <SampleItem> > FetchSampleItemsAsync()
        {
            FetchModelCollectionResult <SampleItem> retResult = new FetchModelCollectionResult <SampleItem>();
            var items = await _database.Table <SampleItem>().ToListAsync();

            retResult.ModelCollection = items;
            return(retResult);
        }
예제 #4
0
        public async Task <FetchModelCollectionResult <T> > FetchItemsAsync <T>() where T : ModelBase, new()
        {
            FetchModelCollectionResult <T> retResult = new FetchModelCollectionResult <T>();
            var items = await _database.Table <T>().ToListAsync();

            retResult.ModelCollection = items;
            return(retResult);
        }
        public async Task Initialize_Call_Pass()
        {
            //Arrange
            FetchModelCollectionResult <Appointment> fetchResult = new FetchModelCollectionResult <Appointment>();

            fetchResult.ModelCollection = new List <Appointment> {
                new Appointment {
                    Name = "Item 1"
                }
            };
            _repoMock.Setup(x => x.FetchAppointmentsAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(new FetchModelCollectionResult <Appointment>());

            //Act
            await _viewModel.InitializeAsync(null);

            //Assert
            _repoMock.VerifyAll();
            Assert.NotNull(_viewModel.Appointments, "Expected collection not to be null");
            Assert.IsTrue(_viewModel.Appointments.Count > 0, "Expected some sample items");
            Assert.IsTrue(_viewModel.Appointments.Contains(fetchResult.ModelCollection[0]), "Expected SampleItems to contain the correct values");
        }
예제 #6
0
        public async Task <FetchModelCollectionResult <Appointment> > FetchAppointmentsAsync(string userId, string providerId)
        {
            FetchModelCollectionResult <Appointment> retResult = new FetchModelCollectionResult <Appointment>();

            var query = _database.Table <Appointment>();

            if (!string.IsNullOrWhiteSpace(userId))
            {
                query = query.Where(x => x.UserId == userId);
            }

            if (!string.IsNullOrWhiteSpace(providerId))
            {
                query = query.Where(x => x.ProviderId == providerId);
            }

            var items = await query.ToListAsync();

            retResult.ModelCollection = items;
            return(retResult);
        }
예제 #7
0
        public async Task <FetchModelCollectionResult <HealthCareProvider> > FetchProvidersAsync(string providerId = null)
        {
            FetchModelCollectionResult <HealthCareProvider> retResult = new FetchModelCollectionResult <HealthCareProvider>();

            try
            {
                var query = _database.Table <HealthCareProvider>();
                if (!string.IsNullOrWhiteSpace(providerId))
                {
                    query = query.Where(x => x.Id == providerId);
                }

                var items = await query.ToListAsync();

                retResult.ModelCollection = items;
            }
            catch (Exception)
            {
                retResult.Notification.Add("Error fetching providers");
            }

            return(retResult);
        }
예제 #8
0
        private async Task FetchAppointmentsAsync()
        {
            ShowBusy("fetching health records");

            try
            {
                FetchModelCollectionResult <Appointment> fetchResult = await _repository.FetchAppointmentsAsync(CurrentUser.Id, null);

                if (fetchResult.IsValid())
                {
                    Appointments = fetchResult.ModelCollection.AsObservableCollection();
                    await Task.Delay(1000); //simulate fetching online data
                }
                else
                {
                    NotBusy();
                    await CC.UserNotifier.ShowMessageAsync(fetchResult.Notification.ToString(), "Fetch Appointments Failed :(");
                }
            }
            finally
            {
                NotBusy();
            }
        }