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);
}