Example #1
0
        public void UpdateItem(SharedSnippetItemData data)
        {
            if (data == null)
            {
                throw new NullParameterException("Item data is null!");
            }
            if (ConnParams == null)
            {
                throw new NullPropertyException("Connection parameters is null!");
            }

            using (SqlConnection conn = new SqlConnection(_connParams.ConnectionString))
            {
                string     cmdText = "exec spPragmaSQL_CodeSnippet_Update @SnippetID, @ParentID, @Name, @Snippet, @Description, @UpdatedBy";
                SqlCommand cmd     = new SqlCommand(cmdText, conn);
                cmd.CommandTimeout = 0;

                AddParam(cmd, "@SnippetID", SqlDbType.Int, data.ID);
                AddParam(cmd, "@ParentID", SqlDbType.Int, data.ParentID);
                AddParam(cmd, "@Name", SqlDbType.VarChar, data.Name);
                AddParam(cmd, "@Snippet", SqlDbType.Text, data.Snippet);
                AddParam(cmd, "@Description", SqlDbType.Text, data.Description);
                AddParam(cmd, "@UpdatedBy", SqlDbType.VarChar, _connParams.CurrentUsername);
                conn.Open();
                cmd.ExecuteNonQuery();
                if (_canSynchronize)
                {
                    SharedSnippetProvider.SynchronizationActionUpdate(data);
                }
            }
        }
Example #2
0
        public void AddItem(SharedSnippetItemData data)
        {
            if (ConnParams == null)
            {
                throw new NullPropertyException("Connection parameters is null!");
            }
            if (data == null)
            {
                throw new NullParameterException("Item data is null!");
            }

            using (SqlConnection conn = new SqlConnection(_connParams.ConnectionString))
            {
                string     cmdText = "exec spPragmaSQL_CodeSnippet_Insert @Type, @ParentID, @Name, @Snippet, @Description, @CreatedBy, @SnippetID out";
                SqlCommand cmd     = new SqlCommand(cmdText, conn);
                cmd.CommandTimeout = 0;

                AddParam(cmd, "@Type", SqlDbType.Int, data.Type);
                AddParam(cmd, "@ParentID", SqlDbType.Int, data.ParentID);
                AddParam(cmd, "@Name", SqlDbType.VarChar, data.Name);
                AddParam(cmd, "@Snippet", SqlDbType.Text, data.Snippet);
                AddParam(cmd, "@Description", SqlDbType.Text, data.Description);
                AddParam(cmd, "@CreatedBy", SqlDbType.VarChar, _connParams.CurrentUsername);
                SqlParameter param = cmd.Parameters.Add("@SnippetID", System.Data.SqlDbType.Int);
                param.Direction = System.Data.ParameterDirection.Output;
                conn.Open();
                cmd.ExecuteNonQuery();
                data.ID = (int?)param.Value;

                if (_canSynchronize)
                {
                    SharedSnippetProvider.SynchronizationActionAdd(data);
                }
            }
        }
Example #3
0
        public void DeleteItem(int?id)
        {
            if (ConnParams == null)
            {
                throw new NullPropertyException("Connection parameters is null!");
            }

            using (SqlConnection conn = new SqlConnection(_connParams.ConnectionString))
            {
                string     cmdText = "exec spPragmaSQL_CodeSnippet_Delete @SnippetID";
                SqlCommand cmd     = new SqlCommand(cmdText, conn);
                cmd.CommandTimeout = 0;
                AddParam(cmd, "@SnippetID", SqlDbType.Int, id);
                conn.Open();
                cmd.ExecuteNonQuery();
                if (_canSynchronize)
                {
                    SharedSnippetProvider.SynchronizationActionDelete(id);
                }
            }
        }