public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Do any additional setup after loading the view.

            // Create the media table data source and populate it
            var DataSource = new MediaTableDataSource();

            MediaTable.DataSource = DataSource;
            MediaTable.Delegate   = new MediaTableDelegate(this, DataSource);

            //Set up goodreads api
            goodreads = new GoodreadsHandler();
        }
        public void SearchMedia()
        {
            //Search database for user query

            //Open database connection
            var conn = GetDatabaseConnection();

            conn.Open();
            var command = conn.CreateCommand();

            //Get search string
            string field  = SearchMediaField.TitleOfSelectedItem;
            string search = SearchMediaSearch.StringValue;

            command.CommandText = string.Format("SELECT * FROM media WHERE {0} LIKE '{1}';", field, search);

            //Get IDs of matching results
            SQLiteDataReader reader    = command.ExecuteReader();
            List <string>    recordIDs = new List <string>();

            while (reader.Read())
            {
                string ID = reader.GetString(0);
                recordIDs.Add(ID);
            }
            conn.Close();

            //Get media records and update table
            var DataSource = new MediaTableDataSource();

            foreach (string ID in recordIDs)
            {
                var record = new MediaModel();
                record.Load(conn, ID);
                DataSource.MediaRecords.Add(record);
            }
            MediaTable.DataSource = DataSource;
            MediaTable.Delegate   = new MediaTableDelegate(this, DataSource);
            MediaTable.ReloadData();
        }
 public MediaTableDelegate(ViewController controller, MediaTableDataSource datasource)
 {
     this.Controller = controller;
     this.DataSource = datasource;
 }