title: Where do I add this "ControllerHelpers" class?
body: <p>In a pretty old .NET tutorial, "Nerd Dinner", it talks about using a Helper Class for Rule Violations. Everything seems straight forward except I'm not sure where to put this class so I can reference it. I am pretty new at MVC.</p>
  
  <p>All of this below was taken from <a href="http://www.asp.net/mvc/overview/older-versions-1/nerddinner/provide-crud-(create,-read,-update,-delete)-data-form-entry-support" rel="nofollow" title="Nerd Dinner">Nerd Dinner Tutorial</a>:</p>
  
  <p>Using a AddRuleViolations Helper Method</p>
  
  <p>Our initial HTTP-POST Edit implementation used a foreach statement within its catch block to loop over the Dinner object's Rule Violations and add them to the controller's ModelState collection:</p>
  
  <pre><code>catch {
      foreach (var issue in dinner.GetRuleViolations()) {
          ModelState.AddModelError(issue.PropertyName, issue.ErrorMessage);
      }
  
      return View(dinner);
  }
  </code></pre>
  
  <p><strong>We can make this code a little cleaner by adding a "ControllerHelpers" class to the NerdDinner project, and implement an "AddRuleViolations" extension method within it that adds a helper method to the ASP.NET MVC ModelStateDictionary class.</strong> This extension method can encapsulate the logic necessary to populate the ModelStateDictionary with a list of RuleViolation errors:</p>
  
  <p>public static class ControllerHelpers {</p>
  
  <p>public static void AddRuleViolations(this ModelStateDictionary modelState, IEnumerable errors) {</p>
  
  <pre><code>   foreach (RuleViolation issue in errors) {
         modelState.AddModelError(issue.PropertyName, issue.ErrorMessage);
     }
  </code></pre>
  
  <p>}
  }</p>