CSLA Asp.net Mvc 2 CslaModelBinder Implementation

CSLA Asp.net Mvc 2 CslaModelBinder Implementation

Old forum URL: forums.lhotka.net/forums/t/10472.aspx


mfmaher posted on Tuesday, June 28, 2011

Was wondering if you have a sample of the CslaModelBinder Implementation for Asp.net Mvc 2. I downloaded the samples for both 3.8.3 and 4.0. I'm looking for a way to implement the BrokenRules Valdation to the View? It was my understanding that the CslaModelBinder was going to handle the BrokenRules Valdation that is being held in the Current Object. But do I need to traverse through the BrokenRules collection like below?

if (!customer.IsValid)
{    

 foreach (Csla.Validation.BrokenRule brokenRule in customer.BrokenRulesCollection)   
 {       

ModelState.AddModelError(brokenRule.Property, brokenRule.Description); 

 }   

viewData.Titles = TitleInfoList.GetTitleInfoList();   
viewData.CurrentCustomer = customer;   
viewData.ValidationErrorFlag = true;   
return View

}

 

mfmaher replied on Tuesday, June 28, 2011

Please disregard this last request. I found the answer. I was omitting the TryUpdate<T>(obj) && SaveObject<T>(obj, true)

 

Thanks

 Mike

Copyright (c) Marimer LLC