コード例 #1
0
        public void Test1()
        {
            FirebaseService firebaseService = new FirebaseService();
            var             activities      = firebaseService.OnceAsync <List <DayProgram> >("DayPrograms").Result[0];
            Activity        activita        = activities[(int)DateTime.Today.DayOfWeek]
                                              .Where(activity => activity.Start <= DateTime.Now.TimeOfDay).LastOrDefault();

            Assert.AreEqual("sleeping", activita.Name);
            Assert.AreEqual(TimeSpan.FromMinutes(1335), activita.Start);
        }
コード例 #2
0
        public async Task Download()
        {
            if (_pageService.IsNetwork().Result == false)
            {
                await _pageService.DisplayNoInternetAlert();

                return;
            }

            try
            {
                _activities = (await _firebaseService.OnceAsync <List <DayProgram> >(_pageService.ReturnId().Result))
                              .FirstOrDefault(); //there is problem
            }
            catch (Exception ex)
            {
                await _pageService.DisplayAlert("er", ex.Message, "OK");
            }

            await _sqLiteService.DeleteAllAsync();

            if (_activities != null)//problem solution
            {
                foreach (DayProgram program in _activities)
                {
                    foreach (Activity activity in program)
                    {
                        activity.Day = _activities.IndexOf(program);
                        await _sqLiteService.InsertAsync(activity);
                    }
                }
                //await _pageService.RestartApp(); //problem solution but if it is enabled, there is IllegalArgumentException
            }
            else
            {
                await _pageService.DisplayAlert("Error", "No data found", "OK");
            }
        }