/// <summary> /// Callback for when the Add Labor 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 AddLaborButton_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 LaborRecordEntry entry = new LaborRecordEntry() { HorseId = HorseManager.GetInstance().ActiveHorse.Id, Date = date }; await AppDatabase.GetInstance().Save <LaborRecordEntry>(entry); // Add a new record view to the stack this.entries.Add(entry); LaborRecordView view = new LaborRecordView(entry); this.LaborRecordStack.Children.Add(view); }
/// <summary> /// Default constructor for the page /// </summary> public LaborRecordEditPage(LaborRecordEntry 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; }