/// <summary> /// Callback for when the Add Riding 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 AddRidingButton_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 RidingRecordEntry entry = new RidingRecordEntry() { HorseId = HorseManager.GetInstance().ActiveHorse.Id, Date = date }; await AppDatabase.GetInstance().Save <RidingRecordEntry>(entry); // Add a new record view to the stack this.entries.Add(entry); RidingRecordView view = new RidingRecordView(entry); this.RidingRecordStack.Children.Add(view); }
/// <summary> /// Default constructor for the page /// </summary> public RidingRecordEditPage(RidingRecordEntry entry) { // Initialize the component NavigationPage.SetHasNavigationBar(this, false); this.BindingContext = this.Entry = entry; InitializeComponent(); // Set the "modified" property of the page to false this._modified = false; }