Пример #1
0
        /// <summary>
        /// Callback for when the Add Bedding button is clicked.
        /// </summary>
        /// <param name="sender">Object that triggered the event.</param>
        /// <param name="e">Arguments for the click event.</param>
        private async void AddBeddingButton_Clicked(object sender,
                                                    EventArgs e)
        {
            // Check if the maximum number of entries for the day is
            // already reached
            if (this.entries.Count >= MAX_ENTRIES_PER_DAY)
            {
                ToastController.ShortToast("Cannot add any more records for the day!");
                return;
            }

            // Create a new record book entry and insert it into the
            // database to obtain a unique Id
            BeddingRecordEntry entry = new BeddingRecordEntry()
            {
                HorseId = HorseManager.GetInstance().ActiveHorse.Id,
                Date    = date
            };
            await AppDatabase.GetInstance().Save <BeddingRecordEntry>(entry);

            // Add a new record view to the stack
            this.entries.Add(entry);
            BeddingRecordView view = new BeddingRecordView(entry);

            this.BeddingRecordStack.Children.Add(view);
        }
Пример #2
0
        /// <summary>
        /// Method for when the page appears.
        /// </summary>
        protected override async void OnAppearing()
        {
            // Invoke the base OnAppearing method
            base.OnAppearing();

            // Set the horse/date display at the page bottom
            this.SelectedDateLabel.Text =
                RecordBookTabbedPage.SelectedDate.ToString("MMM. dd, yyyy");
            this.SelectedHorseLabel.Text =
                HorseManager.GetInstance().ActiveHorse.Name;

            // Get all of the records for the page
            this.entries.Clear();
            this.entries = await RecordBookEntry.GetInRange
                           <BeddingRecordEntry>(HorseManager.GetInstance().ActiveHorse.Id,
                                                this.date,
                                                this.date.AddDays(1));

            // Clear all of the contents from the bedding record stack
            this.BeddingRecordStack.Children.Clear();

            // Render all of the entries on the screen
            foreach (BeddingRecordEntry entry in this.entries)
            {
                // Add a new record frame for each bedding
                Device.BeginInvokeOnMainThread(() => {
                    BeddingRecordView view = new BeddingRecordView(entry);
                    this.BeddingRecordStack.Children.Add(view);
                });
            }
        }