Question
Heres the design for the Store: There are 3 pages, Browse, Index and Details. Browse page will show a list of genre. When a user
Heres the design for the Store:
There are 3 pages, Browse, Index and Details.
Browse page will show a list of genre. When a user clicks on a specific genre(example: Pop), it will take them to another page (Index) with a list of albums that belong to that genre (example: Only albums that are under the Pop genre). When the user clicks on a specific album(example: Frank), another page displays details of that album.
/Store/Browse
Here are the steps to create this Store in MVC:
Create a StoreController
HINT: We are not going to use Entity Framework as there is no need for it in this situation. So, choose MVC5 Controller Empty
Add 3 action methods called as Browse, Details and Index
Browse Actionmethod
Will take no parameters
Is a HTTPGET method
Will query the database (MVCMusicStoreDB), get all genres , make it into a List and send to the Browse view
Make sure you define MVCMusicStoreDB db = new MVCMusicStoreDB(); at the beginning of the class
Create a Browse view under a folder called Store (Empty without model)At the beginning of the view, add the model that it will use (List of Genres):
@model IEnumerable
This view is going to take a list of genres
Hint: Look at StoreManager/Index.cshtml for ideas of how to do this
Set up a foreach loop to go through the list of genres
Display genre names as a link (Hint: Use Html.ActionLink)
Each genre link should be of this format - /Store/Index/Id
(example: http://localhost:57182/Store/Index/10)
Make sure you are sending the genre id to the Index ActionMethod as shown above
Format the view to match my screenshot
Index Action method
This method will take one parameter id that is an integer
Is a HTTPGET method
Will query the database (MVCMusicStoreDB) and get all albums that has the genre id = Id (parameter)
Create an Index view under the folder StoreAt the beginning of the view, add the model that it will use(List of Albums):
@model IEnumerable
This view is going to take a list of Albums
Set up a foreach loop to list all the albumsEach Album entry should be a link of the format /Store/Details/id
Hint: use @Html.ActionLink
For example, make sure when you click on an album with id = 4, that id is being sent to the Details view as /Store/Details/4
Format the view to match my screenshot
Details Action method
This method will take one parameter id that is an integer
Is a HTTPGET method
Will query the database (MVCMusicStoreDB) and get the one album that has the album id = Id (parameter)
Create a Details view under the folder StoreAt the beginning of the view, add the model that it will use (Albums):
@model MVCMusicStoreApplication.Models.Albums
This view is going to take a single album and display the details
Add a button called Add to Cart. This should point to the path /ShoppingCart/AddToCart/id where id is the album id.
Since we dont have any logic for this, when you click on the button it will not work. Dont worry. We will add code next week to this.
Note the book is ASP.NET MVC5
this the below views
Home ASPNET MVC MUSIC STORE Content Body rowse by Genre Classical Metal Reggae 2018-My ASPNET Application Home ASPNET MVC MUSIC STORE Content Body rowse by Genre Classical Metal Reggae 2018-My ASPNET Application
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started