Ejemplo n.º 1
0
 public static bool Delete(string action)
 {
     // Query checks that race is in the right mode, the invitee is not already invited and that the invite limit has not been exceeded
     SQLiteDatabase db = new SQLiteDatabase(true);
     bool deleted = false;
     try
     {
         // This query checks that the user has not already been invited
         string sql = "delete from cycli_content where lower(_action) = lower(@a) ";
         deleted = (db.ExecuteNonQuery(sql, "@a", action) == 1);
         string deletelinksql = "delete from cycli_content_links where sourceaction = @s";
         db.ExecuteNonQuery(deletelinksql, "@s", action);
         db.CommitTransaction();
     }
     catch (Exception ex)
     {
         db.RollbackTransaction();
     }
     finally
     {
     }
     return deleted;
 }
Ejemplo n.º 2
0
        public void Save()
        {
            Updated = DateTime.UtcNow;
            // Query checks that race is in the right mode, the invitee is not already invited and that the invite limit has not been exceeded
            SQLiteDatabase db = new SQLiteDatabase(true);
            try
            {
                // This query checks that the user has not already been invited
                string sql = "select _action from cycli_content where lower(_action) = lower(@a) ";
                string a = db.ExecuteScalar(sql, "@a", this.Action);
                if (string.IsNullOrEmpty(a))
                {
                    // It's a new one
                    sql = "insert into cycli_content (title, body, updated, footerLink, _action) values (@t, @b, @u, @f, @a) ";
                }
                else
                {
                    sql = "update cycli_content set title=@t, body=@b, updated=@u, footerLink=@f where _action=@a";
                }
                db.ExecuteNonQuery(sql, "@t", Title, "@b", Body, "@u",
                    DbTime.ToDbSecs(Updated), "@f", FooterLink.ToString(), "@a", this.Action);

                // Remove any links
                string deletelinksql = "delete from cycli_content_links where sourceaction = @s";
                db.ExecuteNonQuery(deletelinksql, "@s", this.Action);
                // and add new ones
                string insertlinksql = "insert into cycli_content_links (sourceaction, destinationaction) values (@s, @d)";
                foreach (KeyValuePair<string, string> l in Links)
                {
                    db.ExecuteNonQuery(insertlinksql, "@s", this.Action, "@d", l.Key);
                }

                db.CommitTransaction();
            }
            catch (Exception ex)
            {
                db.RollbackTransaction();
            }
            finally
            {
            }
        }