Thursday, March 3, 2011

I've Joined the 2011 Startup Bus!

Chances are, unless you're involved in it you have no idea what the Startup Bus is. I got my ticket bid to join the bus a couple days ago and officially accepted earlier today. Since I have a good deal of preparation I'd like to cram in before the bus rolls out on Tuesday, I'll simply refer you over to their website/blog - http://startupbus.com/. I'm truly thrilled and honored to be able to join a group of talented developers from the Cleveland area in the hopes of establishing a successful startup company!

Monday, February 21, 2011

Retrieving Errors From the .NET MVC ModelState

There's good reason to write extension methods that help adding errors to the .NET MVC ModelState Dictionary, and the Microsoft tutorials present some reasonable, readily-available solutions for this. But you might also desire to get back those errors in the form in which they were added in the first place, and for that it's a little bit trickier. Using the RuleViolation class pattern provided on the asp.net website, the code below uses LINQ query syntax with outer range variables to handle the SelectMany query projection into an IEnumerable<RuleRiolation> collection object.

public static IEnumerable<RuleViolation> GetRuleViolations(this ModelStateDictionary modelState)
        {
            var violations = from vals in modelState
                             from errors in vals.Value.Errors
                             where vals.Value.Errors.Count > 0
                             select new RuleViolation(errors.ErrorMessage, vals.Key);

            return violations;
        }

Sunday, January 9, 2011