Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model IEnumerable<MVCMusicStore.Models.Artist>
- @{
- ViewBag.Title = "Store";
- }
- <h3>Browse Artists</h3>
- @Html.ActionLink("A", "Index", new { letter = "A" })
- @Html.ActionLink("B", "Index", new { letter = "B" })
- @Html.ActionLink("C", "Index", new { letter = "C" })
- @Html.ActionLink("D", "Index", new { letter = "D" })
- @Html.ActionLink("E", "Index", new { letter = "E" })
- @Html.ActionLink("F", "Index", new { letter = "F" })
- @Html.ActionLink("G", "Index", new { letter = "G" })
- @Html.ActionLink("H", "Index", new { letter = "H" })
- @Html.ActionLink("I", "Index", new { letter = "I" })
- @Html.ActionLink("J", "Index", new { letter = "J" })
- @Html.ActionLink("K", "Index", new { letter = "K" })
- @Html.ActionLink("L", "Index", new { letter = "L" })
- @Html.ActionLink("M", "Index", new { letter = "M" })
- @Html.ActionLink("N", "Index", new { letter = "N" })
- @Html.ActionLink("O", "Index", new { letter = "O" })
- @Html.ActionLink("P", "Index", new { letter = "P" })
- @Html.ActionLink("Q", "Index", new { letter = "Q" })
- @Html.ActionLink("R", "Index", new { letter = "R" })
- @Html.ActionLink("S", "Index", new { letter = "S" })
- @Html.ActionLink("T", "Index", new { letter = "T" })
- @Html.ActionLink("U", "Index", new { letter = "U" })
- @Html.ActionLink("V", "Index", new { letter = "V" })
- @Html.ActionLink("W", "Index", new { letter = "W" })
- @Html.ActionLink("X", "Index", new { letter = "X" })
- @Html.ActionLink("Y", "Index", new { letter = "Y" })
- @Html.ActionLink("Z", "Index", new { letter = "Z" })
- @Html.ActionLink("All", "Index", new { letter = "all" })
- <ul>
- @foreach (var artist in Model)
- {
- <li>@Html.ActionLink(artist.Name,
- "Browse", new { id = artist.ArtistId })</li>
- }
- </ul>
- public ActionResult Index(string letter = "")
- {
- IEnumerable<Artist> artist;
- if (letter == "all")
- {
- artist = storeDB.Artists.OrderBy(x =>x.Name).ToList();
- }
- else if (letter != "")
- {
- artist = storeDB.Artists.Where(a => a.Name.StartsWith(letter)).OrderBy(x => x.Name).ToList();
- }
- else
- {
- artist = new List<Artist>();
- }
- @if(Model.Any())
- {
- foreach (var artist in Model)
- {
- <li>@Html.ActionLink(artist.Name,
- "Browse", new { id = artist.ArtistId })</li>
- }
- }
- else
- {
- <span>There are no artists</span>
- }
Add Comment
Please, Sign In to add comment