|
|
 |
BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9
 |
This is the forum to discuss the Wrox book Professional ASP.NET MVC 1.0 by Rob Conery, Scott Hanselman, Phil Haack, Scott Guthrie; ISBN: 978-0-470-38461-9 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |
|

October 8th, 2009, 08:48 AM
|
|
Authorized User
|
|
Join Date: Jun 2009
Posts: 19
Thanks: 0
Thanked 1 Time in 1 Post
|
|
RE: Dinner Controller Class
Yes AbrarP, you're right. I think it should be:
Code:
ModelState.AddRuleViolations(dinner.GetRuleViolations());
because in previous page, we created an extension method
Code:
public static void AddRuleViolations(this ModelStateDictionary modelState, ...)
.
Hope this helps!
S.
|

October 8th, 2009, 10:24 AM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
RE: Dinner Controller Class
This is what the book doesn't say (pg 70-71): The code for the controllerhelper class is all wrong...
Incorrect Code:
Code:
public static class ControllerHelpers {
public static void AddRuleViolations(this ModelStateDictionary
modelState, IEnumerable<RuleViolation> errors) {
foreach (RuleViolation issue in errors) {
modelState.AddModelError(issue.PropertyName,
issue.ErrorMessage);
}
}
}
Correct Code:
Code:
public static class ModelStateHelpers {
public static void AddModelErrors(this ModelStateDictionary modelState, IEnumerable<RuleViolation> errors) {
foreach (RuleViolation issue in errors) {
modelState.AddModelError(issue.PropertyName, issue.ErrorMessage);
}
}
}
|

October 8th, 2009, 11:03 AM
|
|
Authorized User
|
|
Join Date: Jun 2009
Posts: 19
Thanks: 0
Thanked 1 Time in 1 Post
|
|
RE: Dinner Controller Class
You could either change the method definition or ignore the errata for page 71.
S.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |