p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old October 8th, 2009, 08:48 AM
Authorized User
Points: 71, Level: 1
Points: 71, Level: 1 Points: 71, Level: 1 Points: 71, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2009
Posts: 19
Thanks: 0
Thanked 1 Time in 1 Post
Default 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #12 (permalink)  
Old October 8th, 2009, 10:24 AM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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);
            }
        }
    }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #13 (permalink)  
Old October 8th, 2009, 11:03 AM
Authorized User
Points: 71, Level: 1
Points: 71, Level: 1 Points: 71, Level: 1 Points: 71, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2009
Posts: 19
Thanks: 0
Thanked 1 Time in 1 Post
Default RE: Dinner Controller Class

You could either change the method definition or ignore the errata for page 71.

S.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NerdDinner The view 'Index' or its master could not be found rthorington BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 3 May 3rd, 2009 05:30 PM
NerdDinner.Tests Project Missing Stuff dwrogers BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 2 March 22nd, 2009 10:54 AM
More Errors in chapter 7..... rollercoaster BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 5 October 3rd, 2006 04:49 PM
Chapter 6 Try It Out errors Voltron ASP.NET 2.0 Basics 0 August 9th, 2006 02:42 AM
Chapter 4 Errors? DRAYKKO BOOK: Beginning Java 2 3 June 1st, 2004 08:47 AM



All times are GMT -4. The time now is 06:07 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc