public async void FetchAppointmentsForDay(DateTime date)
        {
            try
            {
                List <CheckIn> checkins = await _apiService.GetAllBetweenDatesAsync <CheckIn>("checkins", date, date.AddDays(1));

                appointmentTimes = checkins.Where(x => x.IsAppointment == true).Select(x => x.AppointedTo.Value.TimeOfDay).ToList();
            }
            catch (Flurl.Http.FlurlHttpException ex)
            {
                appointmentTimes = new List <TimeSpan>()
                {
                    TimeSpan.FromMinutes(3 * 60 + 10),
                    TimeSpan.FromMinutes(3 * 60 + 20),
                    TimeSpan.FromMinutes(3 * 60 + 30),
                    TimeSpan.FromMinutes(8 * 60 + 10),
                    TimeSpan.FromMinutes(3 * 60 + 10),
                    TimeSpan.FromMinutes(10 * 60 + 50),
                    TimeSpan.FromMinutes(3 * 60 + 10),
                    TimeSpan.FromMinutes(3 * 60 + 10),
                    TimeSpan.FromMinutes(3 * 60 + 10),
                    TimeSpan.FromMinutes(3 * 60 + 10),
                    TimeSpan.FromMinutes(3 * 60 + 10),
                    TimeSpan.FromMinutes(3 * 60 + 10),
                    TimeSpan.FromMinutes(3 * 60 + 10),
                    TimeSpan.FromMinutes(3 * 60 + 10),
                };
                Console.WriteLine("Yeeted");
            }
            AppointmentsForDateItemsControl.ItemsSource = appointmentTimes;
        }
示例#2
0
        /// <summary>
        /// Begins synchronization.
        /// </summary>
        public async Task Start()
        {
            if (_apiService == null)
            {
                Console.WriteLine("That's dope man.");
            }
            DateTime today    = DateTime.Now.Subtract(DateTime.Now.TimeOfDay);
            DateTime tomorrow = today.AddDays(1);
            List <T> list;

            try
            {
                list = await _apiService.GetAllBetweenDatesAsync <T>(_apiResourceUri, today, tomorrow);
            }
            catch (Flurl.Http.FlurlHttpException ex)
            {
                throw;
            }
            Console.WriteLine("Number of initial elements: " + list.Count);
            if (list.Count > 0)
            {
                _repository.AddRange(list);
                NewData?.Invoke(this, new DataSyncEventArgs <T>()
                {
                    ChangedElements = list
                });
            }
            //foreach (T item in _repository.Cast<T>())
            //{
            //    Console.WriteLine(item.GetSyncId());
            //}
            _timer.Start();
        }
示例#3
0
        private async Task <List <T> > ItemsAlteredFetchFunc(IRESTService apiService, string resourceUri, DateTime syncByDate)
        {
            //Console.WriteLine("Syncing by date: {0}", syncByDate);
            DateTime today    = DateTime.Now.Subtract(DateTime.Now.TimeOfDay);
            DateTime tomorrow = today.AddDays(1);

            return(await apiService.GetAllBetweenDatesAsync <T>(resourceUri, syncByDate, tomorrow, null, true));

            //return await _apiService.GetAllAfterDateAsync<T>(resourceUri, new DateTime(), syncBy);
        }
示例#4
0
        /// <summary>
        /// The default function for API calls if no delegate is passed in the constructor.
        /// </summary>
        /// <param name="apiService">The IRESTService instance to be used to make the API call.</param>
        /// <param name="resourceUri">The URL path beyond the base URL.</param>
        /// <param name="syncBy">The value to sync by, elements with greater Id will be returned.</param>
        /// <returns>List of new T elements, may be empty.</returns>
        private async Task <List <T> > DefaultDatabaseFetchFunc(IRESTService apiService, string resourceUri, int syncBy)
        {
            //Console.WriteLine("Sync by id: {0}", syncBy);
            DateTime today    = DateTime.Now.Subtract(DateTime.Now.TimeOfDay);
            DateTime tomorrow = today.AddDays(1);

            return(await apiService.GetAllBetweenDatesAsync <T>(resourceUri, today, tomorrow, syncBy > -1?syncBy : (int?)null));

            //return await _apiService.GetAllAfterDateAsync<T>(resourceUri, new DateTime(), syncBy);
        }