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