Implement QuickEdit in Pre-populated website

Apr 14, 2011 at 1:37 PM

G'day Guys,

First of all this is a fantastic helper - I am a recent convert from the world of PHP and I have grown quite fond of the Razor syntax!

I want to implement Quickedit on to a website that I have already developed that is SQL driven. By looking at the code, it would seem if I made some minor changes to the queries - I should be able to achieve what I need to. Before I do that, has anyone else had any luck with it?

Here is what I was looking at editing: 



 public static string GetContent(string contentKey) {
        var db = Database.Open(ConnectionString);
        var contentValue = db.QueryValue("SELECT [Value] FROM webpages_QuickEditContent WHERE [Key] = @0", contentKey);

        if (contentValue == null) {
            contentValue = HttpUtility.HtmlEncode(EmptyKeyValue);
            db.Execute("INSERT webpages_QuickEditContent([Key], [Value]) VALUES(@0, @1)", contentKey, contentValue);
        return contentValue;
    /// <summary>
    /// Stores content data into the content storage
    /// </summary>
    /// <param name="contentKey">The content key.</param>
    /// <param name="contentValue">The content data.</param>
    public static void SaveContent(string contentKey, string contentValue) {
        var db = Database.Open(ConnectionString);
        db.Execute("UPDATE webpages_QuickEditContent SET [Value] = @0 WHERE [Key] = @1", contentValue, contentKey);
    private static void InitializeDB() {               
        var db = Database.Open(ConnectionString);
        var table = db.QuerySingle("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'webpages_QuickEditContent'");

    /// Will not need this probably    
        if (table == null) {
            db.Execute("CREATE TABLE webpages_QuickEditContent(Id bigint IDENTITY(1,1) NOT NULL, [Key] nvarchar(100) NOT NULL, Value ntext NOT NULL DEFAULT(''))");


Apr 14, 2011 at 1:49 PM

I answered my own question - by changing the values highlighted above.. I can adapt Quickedit Helper to anything :DD!

--Ignore Previous Post--