Пример #1
0
        void OnItemTapped(object sender, ItemTappedEventArgs e)
        {
            // Fetch the work record from the row tapped
            var record = e.Item as Record;

            // Prepare the dialog with this data
            var recPage = new WorkRecordPage(record);

            recPage.onRecordUpdated += (rec) =>
            {
                // React by updating the model
                this.BeginRefresh();

                // Let's see what happened to the record

                if (rec.user_id == 0) // it was deleted
                {
                    // Delete based on the user id
                    records.remove(rec.id);
                }
                else // it was updated
                {
                    // Update its data based on the user id
                    records.replace(rec.id, rec);
                }

                this.EndRefresh();
            };

            // Present the dialog
            App.mainNav.PushAsync(recPage, true);
        }
Пример #2
0
        /**
         * Adds a new work record based on the details provided.
         * Called when the "+" button in the page header is hit.
         * Calls the dialog, waits for the result and tells the
         * listview to update (add newly created item)
         */
        private void addRecord()
        {
            // Prepare the new work's record
            var newRecord = new Record();

            // Prepare the dialog with this data
            var workPage = new WorkRecordPage(newRecord);

            workPage.onRecordUpdated += (recAdded) =>
            {
                if (recAdded == null)
                {
                    // something went wrong there
                    return;
                }

                // Inform the list view of a new item
                lvWork.itemAdded(recAdded);
            };

            // Present the dialog
            App.mainNav.PushAsync(workPage, true);
        }