<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Phil Derksen</title>
	<atom:link href="http://philderksen.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://philderksen.com</link>
	<description>Web Development, WordPress and SEO</description>
	<lastBuildDate>Fri, 10 Feb 2012 01:10:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>7 Reasons to Build your Contractor or Small Business Website in WordPress</title>
		<link>http://philderksen.com/2010/contractor-small-business-website-wordpress/</link>
		<comments>http://philderksen.com/2010/contractor-small-business-website-wordpress/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 06:08:45 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://philderksen.com/?p=412</guid>
		<description><![CDATA[If you're an independent contractor or run a small business, but you don't have a website, why not?

Let me guess. To you it doesn't sound like it's worth the money, effort or time to create one. For many of you, this might've been true in the past. But not now.

It's 2010. More people search online for what you do than you think. Websites are much easier, cheaper and quicker to create than even just a few years ago. It very likely may take only one or two people to find you online and become your customer to make this effort worthwhile.

What you need to use is WordPress. There are hundreds of frameworks out there to build websites, but in the 15 years I've been developing for the web, I believe WordPress is by far the best platform for independent contractors and small businesses.]]></description>
			<content:encoded><![CDATA[<p style="float:right; margin:0 0 10px 15px; width:240px;">
		<img src="http://philderksen.com/wp-content/uploads/2010/10/wordpress-blue-xl1-e1286433749414.png" width="240" title="wordpress blue xl1 e1286433749414" alt="wordpress blue xl1 e1286433749414" />
		</p><p><img class="alignright size-full wp-image-452" title="WordPress" src="http://philderksen.com/wp-content/uploads/2010/10/wordpress-blue-xl1-e1286433749414.png" alt="wordpress blue xl1 e1286433749414" width="200" height="200" /></p>
<p>If you&#8217;re an independent contractor or run a small business, but you don&#8217;t have a website, why not?</p>
<p>Let me guess. To you it doesn&#8217;t sound like it&#8217;s worth the money, effort or time to create one. For many of you, this might&#8217;ve been true in the past. But not now.</p>
<p>It&#8217;s 2010. More people search online for what you do than you think. Websites are much easier, cheaper and quicker to create than even just a few years ago. It very likely may take only one or two people to find you online and become your customer to make this effort worthwhile.</p>
<p>What you need to use is WordPress. There are hundreds of frameworks out there to build websites, but in the 15 years I&#8217;ve been developing for the web, I believe WordPress is by far the best platform for independent contractors and small businesses.</p>
<p><em>Note that I&#8217;m referring to the downloadable version at </em><em><a title="WordPress.org" href="http://wordpress.org/">WordPress.org</a></em><em>, not the service provided WordPress.com. I&#8217;ll get to that later.</em></p>
<h3>Why WordPress?</h3>
<p><strong>1. You can hold off on hiring a programmer or designer.</strong> For what you need to get up and running quickly with a clean look, you don&#8217;t need to hire out programming or design services. The overall look and feel of a WordPress site is determined by it&#8217;s theme, and there are literally hundreds of thousands of free and premium themes out there to pick from. Choose a decent premium WordPress theme for $100 or less and be done with it. I suggest checking out <a href="http://www.woothemes.com/amember/go.php?r=12202">WooThemes</a> for starters.</p>
<p>Wait until you can afford spending on a custom brand, logo and identity. What&#8217;s most important right now is launching your site.</p>
<p><strong>2. Hosting is cheap and easy.</strong> You can get reliable, quality hosting for less than $10 per month. Plain and simple. There are many good hosts out there, but I use <a href="http://www.dreamhost.com/r.cgi?639722">DreamHost</a>. They have a one-click install for WordPress to make setup as fast and easy as possible. So even though you&#8217;re using a downloadable/installable version of WordPress, you don&#8217;t have to download or install anything. The web hosting service does it for you. That&#8217;s all there is to it.</p>
<p><strong>3. Search Engine Optimization.</strong> WordPress is built for <a href="http://en.wikipedia.org/wiki/Search_engine_optimization">SEO</a> out of the box. It doesn&#8217;t take a whole lot of effort for Google and other search engines to periodically catalog your site and all the key terms within your content. SEO is a topic I&#8217;ll cover in more detail in future posts, but just know that WordPress removes a lot of technical hurdles surrounding SEO that you&#8217;ll never have to worry about. Basically, you just need to focus on the content. WordPress will make it search engine friendly.</p>
<div id="attachment_427" class="wp-caption alignright" style="width: 160px"><a href="http://philderksen.com/wp-content/uploads/2010/10/wordpress-post-editing.png"><img class="size-thumbnail wp-image-427 " title="wordpress post editing" src="http://philderksen.com/wp-content/uploads/2010/10/wordpress-post-editing-150x150.png" alt="wordpress post editing 150x150" width="150" height="150" /></a><p class="wp-caption-text">WordPress post editing</p></div>
<p><strong>4. Simple website administration.</strong> Editing a WordPress site is even easier than creating it. Login to the administration area, create a new post, and start typing. You&#8217;ll set a few options like the title, link, categories and tags. You might add some images or embed a video. There&#8217;s no software involved. Just edit and publish. It&#8217;s just about as simple as creating a Word doc or formatting an email message. No more hiring your nephew or calling up a webmaster to edit some HTML for you just to correct a typo.</p>
<p><strong>5. It&#8217;s fast!</strong> Assuming you&#8217;re using a decent web host (such as <a href="http://www.dreamhost.com/r.cgi?639722">DreamHost</a>) and not cluttering up your pages with too many bells and whistles, your pages should load pretty fast out of the gates. Add a few simple caching and optimization plugins and it loads even faster. If you&#8217;re traffic builds to astronomical numbers, your host should be able to move you to a beefed up server behind the scenes. Many of the world&#8217;s top blogs use WordPress and don&#8217;t blink an eye at thousands of hits a second.</p>
<p><strong>8. Everyone else is doing it.</strong> Some sources say around <a href="http://blog.page.ly/2010/08/the-prolific-wordpress-infographic/">8.5% of all websites are powered by WordPress</a>. There&#8217;s a lot of advantages for using the same platform as a lot of other people. WordPress is open source, and the developer/designer community that surrounds it is astounding. This means you have thousands of themes and thousands of plugins to choose from for very specific needs. For example, click on the image thumbnail above. At the time of this post, I added the <a href="http://wordpress.org/extend/plugins/lightbox-2/">Lightbox plugin</a> to create the effect of showing the full-size image on top of the page while dimming the background.</p>
<p>Whenever you run into an issue, if you search for it chances you&#8217;ll find a ton of posts on it. You&#8217;ll find many developers and designers (local and overseas) well versed in WordPress if you get to the point where you need to hire some help.</p>
<p><strong>7. Create a website, blog or preferably both.</strong> WordPress was originally built as a blogging platform, but it&#8217;s become the most popular content management system (CMS) as well. That&#8217;s because at the very base level you have Pages and Posts. Pages are meant for content that only changes occasionally, like a Contact page or a description of services. Blogging consists of posts, which are meant for frequent updates and usually include a comments area. On my site, what you&#8217;re reading is a post, and <a href="/about/">About</a> is a page. WordPress goes into <a href="http://codex.wordpress.org/Pages">detail on the differences</a> if you&#8217;re interested.</p>
<p>That being said, for a small business or contractor website, you&#8217;re probably thinking a few pages is enough. But to be found by search engines and to engage customers, regular updates (posts) are a good idea. If it sounds like too much work, shoot for posting just once a month for starters. I&#8217;ll wager that you&#8217;ll be surprised how you climb in search engine rankings and visitor numbers from this act alone.</p>
<h3>OK, I want to create a WordPress site. Now what?</h3>
<ul>
<li>The best thing you can do is start creating content, even before WordPress is setup. What will go in your pages? What are some topics you can blog about? Are there some other sites in your industry that you look up to? How do they describe their services? Use a Word doc or Google doc to start typing out drafts. You can always paste them into WordPress later.</li>
<li>If photos apply to your work, start gathering and organizing them. You&#8217;ll want to insert them within text, but you can also create <a href="http://nextgen-gallery.com/gallery-page/">gallery pages</a>. My wife is an excellent <a href="http://www.derksenphotographyblog.com/">baby and family photographer</a> so her WordPress blog is naturally focused on photos.</li>
<li>Start browsing themes and bookmark a few that you like. Decide on one and purchase it.</li>
<li>Go through a few web hosting services and find one that looks trustworthy and reliable to you.</li>
<li>If you don&#8217;t have a domain name, start coming up with ideas. Ending in .com is still the best. I&#8217;ll detail my process for finding domain names in a future post.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2010/contractor-small-business-website-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>April 2010 Fresno-area .NET user group wrap up</title>
		<link>http://philderksen.com/2010/april-2010-fresno-net-user-group/</link>
		<comments>http://philderksen.com/2010/april-2010-fresno-net-user-group/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 22:26:13 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Tech in Fresno]]></category>
		<category><![CDATA[fresno dev]]></category>

		<guid isPermaLink="false">http://philderksen.com/?p=248</guid>
		<description><![CDATA[I haven't been able to make it out to the Fresno-area .NET user group in a while, but I'm glad I did for the one this last Wednesday (held at Fresno State).

The topic of the night was NHibernate (and several related technologies) given by Jeff Doolittle. Jeff's the CTO of Lotpath (built on ASP.NET MVC), so he and his company are definitely eating their own dogfood with what he presented. The slides and code are available which will be great for review for anyone diving into it.]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t been able to make it out to the <a href="http://www.centralcaldotnet.com/">Fresno-area .NET user group</a> in a while, but I&#8217;m glad I did for the one this last Wednesday (held at Fresno State).</p>
<p>The topic of the night was <a href="http://nhforge.org">NHibernate</a> (and several related technologies) given by Jeff Doolittle. Jeff&#8217;s the CTO of <a href="http://www.lotpath.com/">Lotpath</a> (built on ASP.NET MVC), so he and his company are definitely eating their own dogfood with what he presented.</p>
<div class="woo-sc-box download   "><a href="http://www.agilification.com/post/NHibernate-Demo-Slides-and-Code.aspx">Download the slides and code</a></div>
<p>After the presentation and questions, quite a bit of networking went on. I talked to several developers I hadn&#8217;t before, including a recent FSU grad who&#8217;s been developing iPhone and Android apps for <a href="http://www.watchdoit.com/">Watch Do It</a>. Swag, books and full-on software licenses were raffled out at the end as well (I won a copy of <a href="http://www.jetbrains.com/resharper/">ReSharper</a>!). Even after we were kicked out, several of us hit Doghouse Grill for another hour or so.</p>
<p>Needless to say, if you&#8217;re a developer in Fresno, this is definitely a good group to attend and meet other local geeks at. The subject matter spans quite a bit, half the time not even .NET specific. Thanks to <a href="http://www.tinyfit.com/">Gustavo Cavalcanti</a>, who&#8217;s been organizing this user group for some time now. <a href="mailto:gustavo@centralcaldotnet.com">Send him an email</a> if you want to get on the list. The next one is on May 13.</p>
<p>That being said, there&#8217;s also groups for <a href="http://groups.drupal.org/fresno">Drupal</a>, <a href="http://fresnodesignalliance.org">designers</a>, and <a href="http://www.facebook.com/smcfresno">social media</a>. I&#8217;m sure there&#8217;s more, so let us know.</p>
<p>In addition, check out the <a href="http://fresnotech.pbworks.com">Fresno-area techies wiki</a>. Request access, add yourself to the directory, and post any local events such as this one.</p>
<p>Next up: the <a href="http://www.59daysofcode.com/">59 Days of Code</a> kicks off on Friday, April 23 at 10pm. Hope to see some of you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2010/april-2010-fresno-net-user-group/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Agile Zen, a web app built with ASP.NET MVC 2 and jQuery</title>
		<link>http://philderksen.com/2010/agile-zen-asp-net-mvc-2-jquery/</link>
		<comments>http://philderksen.com/2010/agile-zen-asp-net-mvc-2-jquery/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 21:16:48 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://philderksen.com/?p=221</guid>
		<description><![CDATA[I was fortunate enough to attend Microsoft's MIX conference for the first time this year. I learned a ton, jotted down hundreds of ideas for my projects, and had some valuable discussions with a lot of smart people.

Obviously you have to attend in person to network, but fortunately all the videos and slides are being made available online. Even for attendees this is great for review, but also because you inevitably miss a ton of sessions because of the schedule.

At the very end, I attended a great session by the co-founder and developer of Agile Zen, Nate Kohari. It's a unique project management web app written in ASP.NET MVC 2 and jQuery. ]]></description>
			<content:encoded><![CDATA[<p>I was fortunate enough to attend Microsoft&#8217;s <a href="http://live.visitmix.com/">MIX conference</a> for the first time this year. I learned a ton, jotted down hundreds of ideas for my projects, and had some valuable discussions with a lot of smart people.</p>
<p>Obviously you have to attend in person to network, but fortunately all the videos and slides are being made available online. Even for attendees this is great for review, but also because you inevitably miss a ton of sessions because of the schedule.</p>
<p>At the very end, I attended a great session by the co-founder and developer of <a href="http://www.agilezen.com/">Agile Zen</a>, <a href="http://twitter.com/nkohari">Nate Kohari</a>. It&#8217;s a unique project management web app written in ASP.NET MVC 2 and jQuery. Nate&#8217;s the sole developer and this is his major product. It&#8217;s a business that charges for certain levels of usage, not a free-to-use or open source app created for fun. It was refreshing to go through something more in line with my own goals. <a href="http://live.visitmix.com/MIX10/Sessions/EX10">See the video and slides for yourself</a>.</p>
<p>Some of the technology Zen is using:</p>
<ul>
<li>ASP.NET MVC 2</li>
<li>jQuery &amp; <a href="http://jqueryui.com/">jQuery UI</a></li>
<li><a href="http://jsclass.jcoglan.com/">JS.Class</a> (OO JavaScript)</li>
<li><a href="http://nhforge.org">NHibernate</a> ORM</li>
<li><a href="http://sparkviewengine.codeplex.com/">Spark View Engine</a></li>
</ul>
<p>My plan is to convert <a href="http://outofeggs.com/">Out  of  Eggs</a> to ASP.NET MVC 2, then explore some of these other technologies for use within it and other projects I&#8217;m currently working on.</p>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2010/agile-zen-asp-net-mvc-2-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing 59 Days of Code (a Fresno-area web &amp; mobile app competition)</title>
		<link>http://philderksen.com/2010/59-days-of-code-web-mobile-app-competition/</link>
		<comments>http://philderksen.com/2010/59-days-of-code-web-mobile-app-competition/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 00:06:01 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[Tech in Fresno]]></category>
		<category><![CDATA[fresno dev]]></category>

		<guid isPermaLink="false">http://philderksen.com/?p=209</guid>
		<description><![CDATA[I'm excited to announce the CVBI is officially kicking off a web &#038; mobile app showcase/competition for the Fresno area:

59daysofcode.com
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m excited to announce the <a href="http://cvbi.org/">CVBI</a> is officially kicking off a web &amp; mobile app showcase/competition for the Fresno area.</p>
<p><a href="http://59daysofcode.com">59daysofcode.com</a></p>
<p>Fresnans know all too well that we&#8217;re not commonly referred to as a hub for tech startups and talent, so this is  definitely a boon for the local community. Sure, I&#8217;m stoked to enter <a href="http://outofeggs.com">Out of Eggs</a> into the &#8220;In Progress&#8221; category of the contest. And it would definitely be nice to win a prize. But more importantly, I&#8217;m eager to see all the other apps that join in along with their enthusiasm and creativity. And will this competition significantly boost recognition of local talent by the community and investors? I sure hope so.</p>
<p>Also see:</p>
<p><a href="http://twitter.com/59daysOfCode">http://twitter.com/59daysOfCode</a><br />
<a href="http://blog.irmsgeekwork.com/2010/the-59daysofcode-web-mobile-apps-competition">http://blog.irmsgeekwork.com/2010/the-59daysofcode-web-mobile-apps-competition</a></p>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2010/59-days-of-code-web-mobile-app-competition/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Out of Eggs, a web app built in ASP.NET MVC, jQuery &amp; jQuery UI</title>
		<link>http://philderksen.com/2009/out-of-eggs-asp-net-mvc-jquery-jquery-ui/</link>
		<comments>http://philderksen.com/2009/out-of-eggs-asp-net-mvc-jquery-jquery-ui/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 22:26:55 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[fresno dev]]></category>

		<guid isPermaLink="false">http://philderksen.com/?p=188</guid>
		<description><![CDATA[I'm excited to announce outofeggs.com, a web app I've been working on for a while. It's built on the techniques I've gone through in my Categorized Item List series (using ASP.NET MVC, jQuery &#038; jQuery UI). Just create a list and see for yourself. The back end is SQL Server 2008.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m excited to announce <a href="http://outofeggs.com">outofeggs.com</a>, a web app I&#8217;ve been working on for a while. It&#8217;s built on the techniques I&#8217;ve gone through in my <a href="/2009/series-drag-and-drop-categorized-item-list-jquery-asp-net-mvc/">Categorized Item List series</a> (using ASP.NET MVC, jQuery &amp; jQuery UI). Just create a list and see for yourself. The back end is SQL Server 2008.</p>
<p>It probably goes without saying that I could use any and all feedback: bugs that pop up, features you&#8217;d like to see, usability issues, etc. Also let me know if there&#8217;s any development-related aspects of the app you&#8217;d like me to share in a post that I haven&#8217;t covered yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2009/out-of-eggs-asp-net-mvc-jquery-jquery-ui/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Drag and Drop Categorized Item List with jQuery and ASP.NET MVC – Part 4</title>
		<link>http://philderksen.com/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-4/</link>
		<comments>http://philderksen.com/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-4/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 16:15:20 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://philderksen.com/?p=175</guid>
		<description><![CDATA[In this post I’ll go through the controller classes and how to use jQuery and AJAX to update the database with the position (or state) of where each section and item is moved to.

Every section can be dragged and dropped into any of the 4 columns and in any position within that column. This is the reason for both the ColumnNum and SortOrder fields of the Sections table described in part 2.

First we’ll dive into jQuery. Going back to our sortable() call for the sections, we need to add code that fires after an update event. The important thing to note here is that the update event will fire for both the column moving from and to. If moving within the same column, it’ll fire only once.]]></description>
			<content:encoded><![CDATA[<h3>Controllers and AJAX</h3>
<p>This is part 4 of a <a href="/2009/series-drag-and-drop-categorized-item-list-jquery-asp-net-mvc/">series</a>. In this post I’ll go through the controller classes and how to use jQuery and AJAX to update the database with the position (or state) of where each section and item is moved to.</p>
<p>Every section can be dragged and dropped into any of the 4 columns and in any position within that column. This is the reason for both the ColumnNum and SortOrder fields of the Sections table described in <a href="/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-2/">part 2</a>.</p>
<p>First we’ll dive into jQuery. Going back to our sortable() call for the sections, we need to add code that fires after an update event. The important thing to note here is that the update event will fire for both the column moving from and to. If moving within the same column, it’ll fire only once.</p>
<p>As set up in <a href="/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-3/">part 3</a>, the column num is stored in the id attribute of the “listColumn” div, so with a little parsing we can retrieve the column who’s state just changed.</p>
<p>Next we’ll need the new order of the sections within each changed column. The sortable(“serialize”) call forms the section IDs into a “form/ajax submittable string” like this:</p>
<p>section[]=3&amp;section[]=1&amp;section[]=4</p>
<p>For more detail see the <a href="http://jqueryui.com/demos/sortable">jQuery UI sortable</a> page. Look under Methods &gt; serialize.</p>
<p>Now we’ll do an AJAX post to a method within the section controller we’ll create below. Here’s the resulting jQuery:</p>
<pre class="brush: js;">function InitSectionSorting()
{
    $(".listColumn").sortable(
    {
        …,
        //update event fires both for column leaving and receiving
        update: function(event, ui)
        {
            //Extract column num from current div id
            var colNum = $(this).attr("id").replace(/col_/, "");

            $.post("/Section/UpdateSortOrder",
            { columnNum: colNum, sectionIdQueryString: $(this).sortable("serialize") });
        }
    });
}</pre>
<p>In SectionController.cs, we’ll now code the UpdateSortOrder method to receive the serialized string from jQuery and pass it as a string array to it’s model class.</p>
<pre class="brush: csharp;">[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateSortOrder(int columnNum, string sectionIdQueryString)
{
    string[] separator = new string[2] { "section[]=", "&amp;" };
    string[] sectionIdArray = sectionIdQueryString.Split(separator, StringSplitOptions.RemoveEmptyEntries);

    secRepo.UpdateSortOrder(columnNum, sectionIdArray);
    secRepo.Save();

    return Content("Success");
}</pre>
<p>The return Content(“Success”) is simply to see that the update was successful using <a href="http://getfirebug.com/">Firebug</a>. You should see the text “Success” within Firebug’s Console tab after you drag and drop a section. It’s optional so you can remove it.</p>
<p>Now on to Items. They can be moved to any section and in any position, so the jQuery and controller code is almost the same Sections.</p>
<p>jQuery:</p>
<pre class="brush: js;">function InitItemSorting()
{
    $(".itemList").sortable(
    {
        ...,
        //update event fires both for item list leaving and receiving
        update: function(event, ui)
        {
            //Extract section id from parent section box
            var sectionId = $(this).closest(".secBox").attr("id").replace(/section_/, "");

            $.post("/Item/UpdateSortOrder",
                { sectionId: sectionId, itemIdQueryString: $(this).sortable("serialize") });
        }
    });
}</pre>
<p>ItemController.cs:</p>
<pre class="brush: csharp;">[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateSortOrder(long sectionId, string itemIdQueryString)
{
    string[] separator = new string[2] { "item[]=", "&amp;" };
    string[] itemIdArray = itemIdQueryString.Split(separator, StringSplitOptions.RemoveEmptyEntries);

    itemRepo.UpdateSortOrder(sectionId, itemIdArray);
    itemRepo.Save();

    return Content("Success");
}</pre>
<p>In a later series we’ll cover editing the text of (and deleting) sections and items.</p>
<div class="woo-sc-box download   "><a href="http://philderksen.com/wp-content/uploads/2009/10/2009-10-08_CategorizedItemsListDemo.zip">Download the source code</a> (requires Visual Studio 2008 and ASP.NET MVC 1.0)</div>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>12 Mbps+ Broadband Internet Options in Fresno, CA (Fall 2009)</title>
		<link>http://philderksen.com/2009/broadband-internet-options-fresno-fall-2009/</link>
		<comments>http://philderksen.com/2009/broadband-internet-options-fresno-fall-2009/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 23:20:53 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[Tech in Fresno]]></category>

		<guid isPermaLink="false">http://philderksen.com/2009/09/16/high-speed-broadband-internet-options-in-fresno-ca-fall-2009/</guid>
		<description><![CDATA[It’s Fall 2009 and time to upgrade my home internet service. For all those in Fresno, Clovis and the central valley area with similar needs to mine, hopefully this helps.

In Fresno the only real options I know of are AT&#038;T (DSL or “U-verse”) and Comcast (cable). For the last few years we’ve had AT&#038;T’s DSL Elite (6 Mbps @ $35/month), and that’s been fine, but a few things have changed…

Yes, 6 Mbps downstream is a lot already, but these days we’re watching HD-quality video from Netflix, Hulu and other sources (usually streamed or live). The kicker is my wife is now uploading 10+ gigs of pics after a weekend photo shoot and our 768 Kbps upstream just isn’t cutting it.]]></description>
			<content:encoded><![CDATA[<p>It’s Fall 2009 and time to upgrade my home internet service. For all those in Fresno, Clovis and the central valley area with similar needs to mine, hopefully this helps.</p>
<p>In Fresno the only real options I know of are AT&amp;T (DSL or “U-verse”) and Comcast (cable). For the last few years we’ve had AT&amp;T’s DSL Elite (6 Mbps @ $35/month), and that’s been fine, but a few things have changed…</p>
<p><strong>We need more speed&#8230;12 Mbps+ speed!<br />
</strong>Yes, 6 Mbps downstream is a lot already, but these days we’re watching HD-quality video from <a href="http://www.netflix.com">Netflix</a>, <a href="http://www.hulu.com">Hulu</a> and other sources (usually streamed or live). The kicker is my wife is now uploading 10+ gigs of pics after a <a href="http://www.derksenphotographyblog.com/2009/09/16/cabo-san-lucas-mexico/">weekend photo shoot</a> and our 768 Kbps upstream just isn’t cutting it. Here are my &#8220;before&#8221; speed tests:</p>
<p><img class="alignnone" title="AT&amp;T DSL 6 Mbps 1" src="http://www.speedtest.net/result/572385241.png" alt="572385241" width="300" height="135" /> <img class="alignnone" title="AT&amp;T DSL 6 Mbps 2" src="http://www.speedtest.net/result/572385859.png" alt="572385859" width="300" height="135" /></p>
<p><strong>We don’t need a home phone line.<br />
</strong>Actually we haven’t needed one for a while with two cell phones. But now there’s <a href="http://www.google.com/voice">Google Voice</a> for an extra phone number or <a href="http://www.skype.com">Skype</a> and other <a href="http://en.wikipedia.org/wiki/VOIP">VOIP</a> services. Cell service has gotten better at our house recently as well.</p>
<p><strong>We don’t need cable or satellite TV.<br />
</strong>Our current setup consists of a <a href="http://www.tivo.com/dvr-products/tivo-hd-dvr/index.html">Tivo HD DVR</a> with integrated Netflix streaming and <a href="http://www.amazon.com/videoondemand">Amazon VoD</a>. I get excellent HD reception for over-the-air broadcast channels with an outdoor antenna. Plus there are plenty of <a href="http://www.redbox.com">Redbox</a> kiosks and <a href="http://www.blockbuster.com">Blockbusters</a> around the corner while the physical medium for movies still exists. This probably won’t work for hard core sports or movie enthusiasts, but it does for me, my wife and my kids.</p>
<p><strong>Bottom line:</strong> We need faster internet and nothing else for our home. So what’s the best deal…</p>
<p>As usual, both AT&amp;T and Comcast try to bundle packages together. They want you to buy it all: internet, phone and TV. For years it’s always been a hassle to subscribe to their services a la carte. For this reason I had to start on online chat with both companies to work out a deal. At least this removes the hassle of doing it over the phone. Usually someone responds via chat within minutes if not immediately.</p>
<p>Obviously internet coverage will vary by specific location, but here are the options I had at my address in 93720.</p>
<h3><a href="http://www.att.com/u-verse/explore/internet-landing.jsp">AT&amp;T U-Verse</a></h3>
<p>DSL only goes up to 6 Mbps downstream currently, but U-Verse has 12 Mbps and 18 Mpbs downstream options ($55 and $65/month respectively). I assume 1-2 Mbps upstream but I forgot to ask and it doesn’t say.</p>
<p>At first they said I needed to subscribe to at least their TV service in addition to internet to get the $55/month internet price. I said I wasn’t interested and they changed it to no TV service required but a $150 installation charge. Not great, but at least there’s no contract.<a href="http://www.comcast.com/shop/buyflow2/products.cspx?SourcePage=Internet"><strong> </strong></a></p>
<h3><a href="http://www.comcast.com/shop/buyflow2/products.cspx?SourcePage=Internet">Comcast Cable</a></h3>
<p>They have the same 12 Mbps and 18 Mbps downstream options for cheaper than DSL ($43 and $53 respectively). Like AT&amp;T, there’s no contract, but they try and steer you away from a la carte. But in chat I got the “stand-alone” internet offer out of them and whittled it down from a $100 to a $50 installation charge. Tack on $3/month for the modem and I’m at $45/month. They also state a 2 Mbps upstream which if even close is awesome.</p>
<h3>Winner: Comcast</h3>
<p>Bottom line: <span style="text-decoration: line-through;">$10/month cheaper and a $100 cheaper install than AT&amp;T.</span> $17/month cheaper and a $125 cheaper install than AT&amp;T. Pretty easy decision.</p>
<p><strong>Update 9/21/09</strong></p>
<p>Comcast&#8217;s website and online chat say one thing (see below), but when I called 1-800-COMCAST, I found out the above applies to the bay area and not Fresno. What they offer here past their 6 Mbps package is a 16 Mbps package (not 12 or 18) with a 2 Mbps upstream.</p>
<p>The cost is cheaper $35/month + $3/month modem rental + $25 install, but it&#8217;s only good for a year. It&#8217;s not a contract though, so you can cancel anytime. I scheduled my install and plan on doing just that as after a year it doubles to $70/month. At that point I&#8217;ll shop around again for the best deal or attempt to negotiate the existing one.</p>
<p><strong>Update 9/24/09</strong></p>
<p>The Comcast guy just left my house. Initial speed tests rock!</p>
<p><img class="alignnone" title="Comcast Cable 16 Mbps 1" src="http://www.speedtest.net/result/573785558.png" alt="573785558" width="300" height="135" /> <img class="alignnone" title="Comcast Cable 16 Mbps 2" src="http://www.speedtest.net/result/573786615.png" alt="573786615" width="300" height="135" /></p>
<p>The Comcast guy said I should see speeds &#8220;burst&#8221; when downloading larger files or streaming. And BTW, he also claimed that by the end of this year Comcast is rolling out <strong>50 Mbps downstream / 12 Mbps upstream</strong> to all cable modem subscribers in Fresno with this same package. Their lower-cost 6 Mbps downstream package should also double in speed.</p>
<p><strong>Update 10/28/09</strong></p>
<p><a href="http://www.thebusinessjournal.com/tech/2778-comcast-launches-wideband-in-central-valley">The Business Journal reports</a> Comcast&#8217;s &#8220;wideband&#8221; 50 mb/sec is also coming soon. I&#8217;ll post here with new speed tests when I&#8217;m upgraded.</p>
<p><strong>Update 12/4/09</strong></p>
<p>The cost of the modem rental went from $3/month to $5/month (making my cost now $40/month). Tweeted <a href="http://twitter.com/comcastcares">@comcastcares</a> and they said the <a href="http://amzn.com/B001UI2FPE">Motorola SB6120</a> (currently $93) is a good one. Considering buying it.</p>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2009/broadband-internet-options-fresno-fall-2009/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Drag and Drop Categorized Item List with jQuery and ASP.NET MVC – Part 3</title>
		<link>http://philderksen.com/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-3/</link>
		<comments>http://philderksen.com/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-3/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 17:50:49 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://philderksen.com/?p=145</guid>
		<description><![CDATA[In this post I'll go through each of the Views (and the List controller). We already have the three repository classes in the Models folder. Now we need to add three controller classes to the Controllers folder: ListController.cs, SectionController.cs (for categories) and ItemController.cs.]]></description>
			<content:encoded><![CDATA[<h3>Views and Partial Views</h3>
<p>This is part 3 of a <a href="/2009/series-drag-and-drop-categorized-item-list-jquery-asp-net-mvc/">series</a>. In this post I&#8217;ll go through each of the Views (and the List controller). In part 4 I’ll go through the controller classes and how to use jQuery and AJAX to update the database.</p>
<p>We already have the three repository classes in the Models folder. Now we need to add three controller classes to the Controllers folder: ListController.cs, SectionController.cs (for categories) and ItemController.cs.</p>
<p>Next we’ll create a proper View for individual list records. For now we’ll continue to use the single hardcoded list record, so we’ll redirect from the Home controller/Index action to the List controller/Details action with the ID of 1. The List controller code is simply:</p>
<pre class="brush: csharp;">using CategorizedItemsListDemo.Models;

namespace CategorizedItemsListDemo.Controllers
{
    public class ListController : Controller
    {
        private ListRepository listRepo = new ListRepository();

        public ActionResult Details(long id)
        {
            List singleList = listRepo.GetById(id);
            return View(singleList);
        }
    }
}</pre>
<p>For now we don’t need to code up anything in the Section and Item controller classes, so we’ll move on to the views. The parent view we’ll use is the List/Details view. Since we’ll be looping through to add child Section records to the List record, and child Item records to each Section record, we’ll create two “partial views” (one for individual sections, one for individual items). This way user interface markup can be encapsulated without being repetitive (remember DRY – don’t repeat yourself).</p>
<p>Coming from an ASP.NET WebForms background, I equate partial views to the MVC way of doing user controls. They in fact use the same .ascx extension. I also added them to the /Views/Shared folder so the MVC engine can easily locate them. To sum it up, here are the three views added and the containing code:</p>
<p><strong>/Views/List/Details.aspx</strong></p>
<pre class="brush: csharp;">&lt;% for (int i = 1; i &lt;= 4; i++) { %&gt;
    &lt;div class="grid_3 listColumn" id="col_&lt;% =i %&gt;"&gt;
        &lt;% foreach (Section sec in Model.Sections.Where(s =&gt; s.ColumnNum == i).OrderBy(s =&gt; s.SortOrder)) { %&gt;
            &lt;% Html.RenderPartial("SingleSection", sec); %&gt;
        &lt;% } %&gt;
    &lt;/div&gt;
&lt;% } %&gt;</pre>
<p>Here the outside loop is simply going through each of the four columns setting the id attribute to the record id for use in jQuery. The inner loop is going through each Section in the List record (referenced by “Model” since the view is bound to the List model class). It simply uses a Lambda expression to render the Sections in the correct columns in the correct order. Then it passes off each individual Section to the SingleSection partial view.</p>
<p><strong>/Views/Shared/SingleSection.ascx</strong></p>
<pre class="brush: csharp;">&lt;div class="secBox" id="section_&lt;%= Model.SectionId %&gt;"&gt;
    &lt;div class="secHeader"&gt;
        &lt;h2 class="secName"&gt;&lt;%= Html.Encode(Model.SectionName) %&gt;&lt;/h2&gt;
    &lt;/div&gt;

    &lt;div class="itemBox"&gt;
        &lt;ul class="itemList"&gt;
            &lt;% foreach (Item item in Model.Items.OrderBy(i =&gt; i.SortOrder)) { %&gt;
                &lt;% Html.RenderPartial("SingleItem", item); %&gt;
            &lt;% } %&gt;
        &lt;/ul&gt;
    &lt;/div&gt;
&lt;/div&gt;</pre>
<p>Here we’re basically applying the same format from the List view to the Section partial view. Each Section is surrounded by a div with the id attribute set to the record id. “Model” is now bound to the Section model class, which we then use to display the Section name and loop through child Item records. We display Items in the correct sort order using a Lambda expression, then pass off each Item record to another partial view.</p>
<p><strong>/Views/Shared/SingleItem.ascx</strong></p>
<pre class="brush: csharp;">&lt;li class="itemRow" id="item_&lt;%= Model.ItemId %&gt;"&gt;
    &lt;span class="itemName"&gt;&lt;%= Html.Encode(Model.ItemName) %&gt;&lt;/span&gt;
&lt;/li&gt;</pre>
<p><span style="font-family: verdana;"> </span></p>
<p><span style="font-family: verdana;">This partial view is the simplest (for now). Again the id attribute is set to the record id. After that we simply render the item name.</span></p>
<p>That’s it. Now the app is rendering real data using MVC views. Nothing is hardcoded. To get things looking like they did in the initial layout, I populated the SQL database with sample data.</p>
<div class="woo-sc-box download   "><a href="http://philderksen.com/wp-content/uploads/2009/09/2009-09-02_CategorizedItemsListDemo.zip">Download the source code</a> (requires Visual Studio 2008 and ASP.NET MVC 1.0)</div>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tech Company Mentality in Fresno</title>
		<link>http://philderksen.com/2009/tech-company-mentality-fresno/</link>
		<comments>http://philderksen.com/2009/tech-company-mentality-fresno/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 17:10:36 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[Tech in Fresno]]></category>
		<category><![CDATA[fresno dev]]></category>

		<guid isPermaLink="false">http://philderksen.com/?p=125</guid>
		<description><![CDATA[My friend Robert Schultz recently gave his opinion on software programmer mentality in Fresno. I personally think it speaks to a larger issue going on with tech companies themselves in the Fresno/Clovis area.

I was born and raised in Fresno, and for at least 90% of the last 12 years I've been a full-time software developer for 6 different companies in the area. I hate to say it, but with most of them it was only about a year or two before I had to put in my resignation. They all had great people and great potential. But there was always some big setback that eventually caused me to leave.]]></description>
			<content:encoded><![CDATA[<p>My friend Robert Schultz recently gave his opinion on <a href="http://www.robertschultz.org/2009/07/22/software-programmer-mentality-in-fresno/">software programmer mentality in Fresno</a>. I personally think it speaks to a larger issue going on with tech companies themselves in the Fresno/Clovis area.</p>
<p>I was born and raised in Fresno, and for at least 90% of the last 12 years I&#8217;ve been a full-time software developer for 6 different companies in the area. I hate to say it, but with most of them it was only about a year or two before I had to put in my resignation. They all had great people and great potential. But there was always some big setback that eventually caused me to leave.</p>
<p>Most recently my issues with these companies have been with both business direction and how they valued their developers. As engineers, we want to create and have our ideas listened to and our accomplishments valued. Lack of this is the main fault of most of the places I&#8217;ve worked for in Fresno (some more than others of course). Developers should never be treated as just &#8220;task monkeys&#8221; and handed a to-do list of specific items to check off. Many fall into that trap simply because that&#8217;s how it&#8217;s been for them for so long. At the point that it becomes &#8220;just a job&#8221; and they can&#8217;t wait until the clock hits 5 or 6 every day, and that&#8217;s only if they&#8217;re lucky and not forced into overtime.</p>
<p>Some of us have entrepreneurial aspirations and some do not, and that&#8217;s fine. But I think all developers want to contribute ideas and be in on the decision-making process wherever we work. We want to innovate all the time, and from my experience companies around here give little effort if at all to encouraging this process. At companies like Google it’s part of your job description. It’s no secret that sometimes half  their new services came out of their “innovation time” policy. Plenty of startups elsewhere do something similar. Managers and company owners need to be open with their business goals and ask their people to openly discuss ideas and company direction. I know I would enjoy my job more if that was part of my responsibilities.</p>
<p>And I don&#8217;t think companies realize this, but with poor developer treatment  they are taking a huge hit in efficiency. Projects start going in the wrong direction because they&#8217;re not listening to their people. In turn employees start working at a 25% motivation level because they don&#8217;t feel valued. The company starts falling way behind in current technology. Then developers stuck in this old technology realize they&#8217;re not going anywhere with their skills. It&#8217;s a vicious cycle. Developers that get fed up start looking elsewhere for something better, and when they have a tough time finding a better job around Fresno, they leave. That&#8217;s part of the &#8220;brain drain&#8221; we hear about.</p>
<p>Back to company mentality, we&#8217;re still behind in technology for the most part in Fresno from what I&#8217;ve experienced. Where are the companies really using social media or blogging regularly? Why do I still hear more about building Windows apps than mobile apps? Why do all these local companies spend so much time and money hosting their own servers (for internal use or external clients) instead of co-locating? It isn&#8217;t new news anymore that using cloud services (Google, Amazon or otherwise) are much more reliable, speedier and secure. Why are people still maintaining Exchange servers and installing Office on every workstation? Even Microsoft, who benefits from all the companies sticking with “classic” Exchange and Office setups realizes this is inevitable. They can host Exchange for you and are coming out with a <a href="http://www.techcrunch.com/2009/07/13/the-complete-guide-to-microsofts-office-2010/">browser-based version of Office 2010</a>. Even <a href="http://arstechnica.com/software/news/2008/10/washington-dc-latest-to-drop-microsoft-for-web-apps.ars">Washington DC moved to Google Apps</a>. At least consider <a href="http://www.buzzmachine.com/what-would-google-do/">What Would Google Do?</a> This is 2009 people!</p>
<p>Myself and a handful of good developers I know in Fresno are very rooted here and thus determined to find the best place to work that they can. (That or start their own company). For me it&#8217;s because family and friends around here come before my career. Take that away from me and I&#8217;m out to bigger &#8220;tech hubs.&#8221; I know personally some good developers here that aren’t as rooted are just waiting for the right opportunity to leave. The business case for local startups <a href="http://www.robertschultz.org/2009/06/30/outsourcing-plasticjungle-to-the-silicon-jungle/">Plastic Jungle</a> (only local company I’ve seen on <a href="http://www.techcrunch.com/2009/05/21/plastic-jungle-scores-48-million-for-gift-card-marketplace/">TechCrunch</a>) and <a href="http://thebusinessjournal.com/index.php/view-all-blogs/viewpost/1109.html">Vine Global</a> (winner of last year’s <a href="http://fresnobeehive.com/news/2008/10/vine_global_wins_start_it_up_c.html">Start-It-Up contest</a>) to stay put were not enough, so recently they both left.</p>
<p>On behalf of all software developers in Fresno and Clovis (let alone the startup scene and effect on the economy locally), I sure hope this trend turns around soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2009/tech-company-mentality-fresno/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Drag and Drop Categorized Item List with jQuery and ASP.NET MVC – Part 2</title>
		<link>http://philderksen.com/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-2/</link>
		<comments>http://philderksen.com/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-2/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 18:45:33 +0000</pubDate>
		<dc:creator>Phil Derksen</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://philderksen.com/?p=108</guid>
		<description><![CDATA[In this part I’ll describe the database structure and create the model classes needed for basic database interaction. To keep things simple, I went with a SQL Server 2005 Express database as it’s free and easy to create within Visual Studio 2008.]]></description>
			<content:encoded><![CDATA[<h3>Database and Model Classes</h3>
<p>This is part two of a <a href="/2009/series-drag-and-drop-categorized-item-list-jquery-asp-net-mvc/">series</a>. In this part I’ll describe the database structure and create the model classes needed for basic database interaction.</p>
<p>To keep things simple, I went with a SQL Server 2005 Express database as it’s free and easy to create within Visual Studio 2008. To create one, simply right-click on the App_Data folder and select SQL Server database. I named mine ListDemo.mdf.</p>
<p>After the database has been created, double-click on the new .mdf file to open it up. I created three tables: Lists, Sections and Items. Here’s the final database structure:</p>
<p><img style="display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;" title="2009-07-15_db_diagram" src="http://philderksen.com/wp-content/uploads/2009/07/20090715_db_diagram1.png" border="0" alt="20090715 db diagram1" width="352" height="616" /></p>
<p>Make sure to set the keys and relationships appropriately. The first ID field of each table should be the primary key and set to auto-increment. I also recommend turning on cascade delete to make deleting whole sections or lists easier. I’ll get into tying the lists table to a users table later.</p>
<p>In the Sections table, the ColumnNum field is to indicate which of the four DIV columns each section resides in. Values must be between 1 and 4. Once narrowed down to a column, sections are sorted by their SortOrder value. Likewise, in the Items table items are sorted within sections by their SortOrder value.</p>
<p>For now I manually created one record in the List table and named it “Demo List 1”.</p>
<p><img style="display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;" title="2009-07-15_list_table" src="http://philderksen.com/wp-content/uploads/2009/07/20090715_list_table.png" border="0" alt="20090715 list table" width="249" height="91" /></p>
<p>On to the “M” (models) in MVC. Again to keep it simple and quick, I chose to use <a href="http://msdn.microsoft.com/en-us/library/bb386976%28loband%29.aspx">LINQ to SQL</a> even though you could argue I should use <a href="http://msdn.microsoft.com/en-us/library/bb386964%28loband%29.aspx">LINQ to Entities</a>. I added a “LINQ to SQL Classes” item to the Models folder and named it ListDemo.dbml to match the database file. At this point the LINQ to SQL designer should pop open. Just drag the Sections, Lists and Items tables from the database view in the Server Explorer to the designer. When you click Save the LINQ to SQL code is generated for you behind behind the scenes. To view it look at the code-behind file for ListDemo.dbml.</p>
<p>Following a simple MVC convention, I created a model class for each table with the name ending in “Repository.” Specifically, ListRepository.cs, SectionRepository.cs and ItemRepository.cs (saved to the Models folder). Declared at the top of each class is a variable that references the data context. In each of the three classes I needed a method to retrieve a single record by ID. I called this GetById and used the <a href="http://msdn.microsoft.com/en-us/library/bb397947%28loband%29.aspx">Lambda/Method syntax</a> of LINQ. It’s virtually the same in all three classes, but here’s the code for SectionRepository.cs:</p>
<pre class="brush: csharp;">public class SectionRepository
{
    private ListDemoDataContext db = new ListDemoDataContext();

    public Section GetById(long id)
    {
        return db.Sections.Single(s =&gt; s.SectionId == id);
    }
}</pre>
<p>For now I’m going to ignore the ListRepository class since I’m just dealing with the single List record for now. In the Section and Item classes, next I coded up the Insert, Delete and Save methods. In all 3 methods I’m referencing the DataContext object, which has the already generated InsertOnSubmit(), DeleteOnSubmit() and SubmitChanges() methods (among others) in the LINQ to SQL auto-generated code. Here’s the code in SectionRepository.cs, but again it’s very similar in ItemRepository.cs:</p>
<pre class="brush: csharp;">public void Insert(Section sec)
{
    sec.SortOrder = GetNextSectionSortOrderValueByListIdColumnNum(sec.ListId, sec.ColumnNum);
    db.Sections.InsertOnSubmit(sec);
}

public void Delete(Section sec)
{
    //Items deleted via SQL cascade delete
    db.Sections.DeleteOnSubmit(sec);
}

public void Save()
{
    db.SubmitChanges();
}</pre>
<p>When a Section or Item record is inserted, it needs to have a SortOrder value that is one higher than the max SortOrder value that already exists within it’s group (all items within a section, or all sections within a column). Using LINQ I created a private method in each of these two classes to retrieve this value before saving the record. In SectionRepository.cs:</p>
<pre class="brush: csharp;">private int GetNextSectionSortOrderValueByListIdColumnNum(long listId, int colNum)
{
    //Max value is null if no items yet
    int? highestSortValue = (from s in db.Sections
                             where (s.ListId == listId) &amp;&amp; (s.ColumnNum == colNum)
                             select (int?)s.SortOrder).Max();

    return (highestSortValue ?? 0) + 1;
}</pre>
<p>When we drag sections or items around, we are basically re-ordering the SortOrder value (and possibly changing the ColumnNum value for sections). jQuery can pass a string of separated ID values when posting to the server via AJAX, so I created the method UpdateSortOrder with a ColumnNum (for Sections) or SectionId (for Items) parameter along with a string array parameter in the two repositories. In SectionRepository.cs:</p>
<pre class="brush: csharp;">public void UpdateSortOrder(int columnNum, string[] sectionIds)
{
    for (int i = 0; i &lt; sectionIds.Length; i++)
    {
        Section section = GetById(long.Parse(sectionIds[i]));
        section.ColumnNum = columnNum;
        section.SortOrder = i + 1;
    }
}</pre>
<p>To see the final code for all three repository classes, download the sample project at the end of this post.</p>
<p>I know there’s no UI updates in this part of the series, but it’s important to get the database and model classes established before moving on.</p>
<div class="woo-sc-box download   "><a href="http://philderksen.com/wp-content/uploads/2009/07/2009-07-17_CategorizedItemsListDemo.zip">Download the source code</a> (requires Visual Studio 2008 and ASP.NET MVC 1.0)</div>
]]></content:encoded>
			<wfw:commentRss>http://philderksen.com/2009/drag-and-drop-categorized-item-list-jquery-asp-net-mvc-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

