예제 #1
0
        async Task ExecuteLoadPeriodCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Periods.Clear();
                var periods = await DataStoreP.GetPeriodsAsync(true);

                foreach (var period in periods)
                {
                    Periods.Add(period);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #2
0
        public PeriodsViewModel()
        {
            Title              = "Periods";
            Periods            = new ObservableCollection <Period>();
            LoadPeriodsCommand = new Command(async() => await ExecuteLoadPeriodCommand());

            MessagingCenter.Subscribe <NewPeriodPage, Period>(this, "AddPeriod", async(obj, period) =>
            {
                var _period = period as Period;
                Periods.Add(_period);
                await DataStoreP.AddPeriodAsync(_period);
            });
        }