/// <summary>
 /// Cursors to subscription.
 /// </summary>
 /// <returns>The to subscription.</returns>
 /// <param name='cursor'>Cursor.</param>
 private Subscription cursorToSubscription(ICursor cursor)
 {
     Subscription subscription = new Subscription();
       subscription.Description = cursor.GetString(cursor.GetColumnIndex(Subscription.COL_DESCRIPTION));
       subscription.LogoUrl = stringToUrl(cursor.GetString(cursor.GetColumnIndex(Subscription.COL_LOGO_URL)));
       subscription.MygpoLink = stringToUrl(cursor.GetString(cursor.GetColumnIndex(Subscription.COL_MYGPO_LINK)));
       subscription.PositionLastWeek = cursor.GetInt(cursor.GetColumnIndex(Subscription.COL_POSITION_LAST_WEEK));
       subscription.ScaledLogoUrl = stringToUrl(cursor.GetString(cursor.GetColumnIndex(Subscription.COL_SCALED_LOGO_URL)));
       subscription.Subscribers = cursor.GetInt(cursor.GetColumnIndex(Subscription.COL_SUBSCRIBERS));
       subscription.SubscribersLastWeek = cursor.GetInt(cursor.GetColumnIndex(Subscription.COL_SUBSRIBERS_LAST_WEEK));
       subscription.Title = cursor.GetString(cursor.GetColumnIndex(Subscription.COL_TITLE));
       subscription.Url = stringToUrl(cursor.GetString(cursor.GetColumnIndex(Subscription.COL_URL)));
       subscription.Website = stringToUrl(cursor.GetString(cursor.GetColumnIndex(Subscription.COL_WEBSITE)));
       return subscription;
 }
 /// <summary>
 /// Creates the content values.
 /// </summary>
 /// <returns>The content values.</returns>
 /// <param name='sub'>Sub.</param>
 private ContentValues createContentValues(Subscription sub)
 {
     ContentValues values = new ContentValues();
       values.Put(Subscription.COL_DESCRIPTION, sub.Description);
       values.Put(Subscription.COL_LOGO_URL, sub.LogoUrl != null ? sub.LogoUrl.ToString() : string.Empty);
       values.Put(Subscription.COL_MYGPO_LINK, sub.MygpoLink != null ? sub.MygpoLink.ToString() : string.Empty);
       values.Put(Subscription.COL_POSITION_LAST_WEEK, sub.PositionLastWeek);
       values.Put(Subscription.COL_SCALED_LOGO_URL, sub.ScaledLogoUrl != null ? sub.ScaledLogoUrl.ToString() : string.Empty);
       values.Put(Subscription.COL_SUBSCRIBERS, sub.Subscribers);
       values.Put(Subscription.COL_SUBSRIBERS_LAST_WEEK, sub.SubscribersLastWeek);
       values.Put(Subscription.COL_TITLE, sub.Title);
       values.Put(Subscription.COL_URL, sub.Url != null ? sub.Url.ToString() : string.Empty);
       values.Put(Subscription.COL_WEBSITE, sub.Website != null ? sub.Website.ToString() : string.Empty);
       return values;
 }
 /// <summary>
 /// Update the specified subscription.
 /// </summary>
 /// <param name='subscription'>Subscription.</param>
 public void Update(Subscription sub)
 {
     try {
     dbHelper.WritableDatabase.Update(Subscription.TABLE_NAME, createContentValues(sub), Subscription.COL_TITLE + "=?", new string[]{sub.Title});
       }
       catch(Exception exc) {
     throw new Exception("Could not udpate subscription " + sub.Title, exc);
       }
 }
 /// <summary>
 /// Inserts the subscription.
 /// </summary>
 /// <param name='subscription'>Subscription.</param>
 public bool InsertOrUpdate(Subscription sub)
 {
     // attempt to query the database for this item
       ICursor cursor = dbHelper.WritableDatabase.Query(Subscription.TABLE_NAME, null, Subscription.COL_TITLE + "=?", new string[]{sub.Title}, null, null, null);
       if(cursor.Count > 0) {
     Update(sub);
     return false;
       }
       else {
     Insert(sub);
     return true;
       }
 }
 /// <summary>
 /// Insert the specified sub.
 /// </summary>
 /// <param name='sub'>Sub.</param>
 public void Insert(Subscription sub)
 {
     try {
     dbHelper.WritableDatabase.InsertOrThrow(Subscription.TABLE_NAME, null, createContentValues(sub));
       }
       catch(Exception exc) {
     throw new Exception("Could not insert subscription " + sub.Title, exc);
       }
 }
 /// <summary>
 /// Deletes the subscription.
 /// </summary>
 /// <param name='subscription'>Subscription.</param>
 public void DeleteSubscription(Subscription subscription)
 {
     try {
     dbHelper.WritableDatabase.Delete(Subscription.TABLE_NAME, Subscription.COL_TITLE + "=?", new string[]{subscription.Title});
       }
       catch(Exception exc) {
     throw new Exception("Could not delete subscription " + subscription.Title, exc);
       }
 }