Wrox Programmer Forums
|
BOOK: Professional ASP.NET MVC 5
This is the forum to discuss the Wrox book Professional ASP.NET MVC 5 by Jon Galloway, Brad Wilson, K. Scott Allen, David Matson; ISBN: 978-1-118-79475-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 17th, 2016, 10:47 AM
Registered User
 
Join Date: May 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Is this an error?

Shouldn't next paragraph say Genre and ArtistId instead of Album(if not please let me know) to fit the code that comes after?
On Page 58 Last paragraph in View Models says
Quote:
For example, the Album Edit view for the
MVC Music Store needs to populate dropdowns for Genres and Albums in our system, but those
lists don’t fi t in the Album model. To handle this without polluting our Album model with extraneous
information, we can pop the Genre and Album information into the ViewBag, as shown in
Listing 3-5.
So the dropdown is about Genre and Album but the list doesn't fit in the Album model?
Then the code change to ViewBagGenre and ViewBagArtistID.
Code:
public ActionResult Edit(int id = 0)
{
Album album = db.Albums.Find(id);
if (album == null)
{
return HttpNotFound();
}
ViewBag.GenreId = new SelectList(
db.Genres, "GenreId", "Name", album.GenreId);
ViewBag.ArtistId = new SelectList(
db.Artists, "ArtistId", "Name", album.ArtistId);
return View(album);
}

Last edited by shark6552; May 17th, 2016 at 10:48 AM.. Reason: adding question marks
 
Old May 17th, 2016, 12:03 PM
Authorized User
 
Join Date: Jan 2013
Posts: 23
Thanks: 1
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by shark6552 View Post
Shouldn't next paragraph say Genre and ArtistId instead of Album(if not please let me know) to fit the code that comes after?
On Page 58 Last paragraph in View Models says


So the dropdown is about Genre and Album but the list doesn't fit in the Album model?
Then the code change to ViewBagGenre and ViewBagArtistID.
Code:
public ActionResult Edit(int id = 0)
{
Album album = db.Albums.Find(id);
if (album == null)
{
return HttpNotFound();
}
ViewBag.GenreId = new SelectList(
db.Genres, "GenreId", "Name", album.GenreId);
ViewBag.ArtistId = new SelectList(
db.Artists, "ArtistId", "Name", album.ArtistId);
return View(album);
}
I read it the same way, but it would be good to hear from the authors. Please report this at http://www.wrox.com/WileyCDA/WroxTit...Cd-ERRATA.html.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Number: 1064 You have an error in your SQL syntax; check the manual that corre rousseauu BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 0 March 30th, 2014 04:43 AM
file system object error. automation error. library not registered shaamir BOOK: Beginning ASP.NET 4 : in C# and VB 1 September 25th, 2012 09:27 AM
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING ngchpg BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 July 16th, 2012 03:28 AM
SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified soufya BOOK: Beginning ASP.NET 4 : in C# and VB 7 September 14th, 2011 08:08 AM
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.