A number of folks wanted the code from my talk at Mix, specifically the "complete application" example with CRUD (Create, Read, Update, Delete) so here it is.
It's nothing pretty to look at, but it makes a number of points with ASP.NET MVC:
- It uses the Default Routes to do everything.
- It uses a ViewUserControl to avoid duplication in a Form.
- It includes the PagedList<T> that makes Linq to SQL easier in grids.
- It's insanely simple. There's like nothing there and it works well.
- It uses lambdas to generate URLs like:
- Html.ActionLink<ProductController>(c => c.Edit(p.ProductID),"Edit")
- Which says "if someone were to call Edit with ProductID as a parameter, what would the URL look like?" The system will then use the lambda along with the already declared routes and figure out the best URL. This is very DRY and lets us change our URLs in one place and have those changes reflected everywhere.
If you want to run it you need:
I known it's cheesy to do demos with Northwind, and we're actively working on more real world, more interesting samples. That said, I'd much rather show off your code, so if you do something cool and Open Source with MVC, let me know. BTW, I've added an ASP.NET MVC category to this blog.
UPDATE #1: PhilHa updated Brad Abrams older (and much more comprehensive) Northwind code to ASP.NET MVC Preview 2, so you can download that much better code below as well.
UPDATE #2: Looks like ASP.NET MVC Preview 2 runs pretty well on Mono. Anyone want to get Northwind up over there as well?
Hosting By