public bool AddAlbum(AlbumViewModel model)
        {
            try
            {
                using (var db = new SQLite.SQLiteConnection(app.DBPath))
                {
                    int success = db.Insert(new Album()
                    {
                        CollectionId = model.CollectionId,
                        Title = model.Title,
                        Artist = model.Artist,
                        LastFmId = model.LastFmId,
                        MusicBrainzId = model.MusicBrainzId,
                        DateAdded = DateTime.Now,
                        Void = false
                    });
                    if (success != 0)
                        return true;
                }
                return false;
            }

            catch
            {
                return false;
            }
        }
 public AlbumViewModel GetAlbum(int albumId)
 {
     var album = new AlbumViewModel();
     using (var db = new SQLite.SQLiteConnection(app.DBPath))
     {
         var _album = (db.Table<Album>().Where(
             c => c.Id == albumId)).Single();
         album.Id = _album.Id;
         album.CollectionId = _album.CollectionId;
         album.Artist = _album.Artist;
         album.Title = _album.Title;
         album.LastFmId = _album.LastFmId;
         album.MusicBrainzId = _album.MusicBrainzId;
         album.DateAdded = _album.DateAdded;
         album.Void = _album.Void;
     }
     return album;
 }
        public CollectionViewModel GetCollection(int collectionId)
        {
            CollectionViewModel collection = new CollectionViewModel();
            using (var db = new SQLite.SQLiteConnection(app.DBPath))
            {
                var _collection = (db.Table<Collection>().Where(
                    c => c.Id == collectionId)).FirstOrDefault();
                collection.Id = _collection.Id;
                collection.Title = _collection.Title;
                collection.DateCreated = _collection.DateCreated;
                collection.Void = _collection.Void;

                // GET ALBUMS
                var _albums = (db.Table<Album>().Where(
                    c => c.CollectionId == collectionId)).ToList();

                List<AlbumViewModel> albumList = new List<AlbumViewModel>();
                foreach (var _album in _albums)
                {
                    AlbumViewModel album = new AlbumViewModel();
                    album.Id = _album.Id;
                    album.CollectionId = _album.CollectionId;
                    album.Artist = _album.Artist;
                    album.Title = _album.Title;
                    album.LastFmId = _album.LastFmId;
                    album.MusicBrainzId = _album.MusicBrainzId;
                    album.DateAdded = _album.DateAdded;
                    album.Void = _album.Void;
                    albumList.Add(album);
                }
                collection.Albums = albumList;
            }
            return collection;
        }
        /// <summary>
        /// Adds an album to a collection via the bar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SortButton_Click(object sender, RoutedEventArgs e)
        {
            // Get content of button
            Button button = sender as Button;

            var ok = this.flipView.SelectedItem as lfm;

            AlbumViewModel vm = new AlbumViewModel
            {
                Artist = ok.album.artist,
                CollectionId = int.Parse(button.Name),
                DateAdded = DateTime.Now,
                LastFmId = ok.album.id.ToString(),
                MusicBrainzId = ok.album.mbid,
                Title = ok.album.name
            };

            vm.AddAlbum(vm);

        }