Guest User

Untitled

a guest
Jul 20th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. @model IEnumerable<MVCMusicStore.Models.Artist>
  2. @{
  3. ViewBag.Title = "Store";
  4. }
  5.  
  6. <h3>Browse Artists</h3>
  7. @Html.ActionLink("A", "Index", new { letter = "A" })
  8. @Html.ActionLink("B", "Index", new { letter = "B" })
  9. @Html.ActionLink("C", "Index", new { letter = "C" })
  10. @Html.ActionLink("D", "Index", new { letter = "D" })
  11. @Html.ActionLink("E", "Index", new { letter = "E" })
  12. @Html.ActionLink("F", "Index", new { letter = "F" })
  13. @Html.ActionLink("G", "Index", new { letter = "G" })
  14. @Html.ActionLink("H", "Index", new { letter = "H" })
  15. @Html.ActionLink("I", "Index", new { letter = "I" })
  16. @Html.ActionLink("J", "Index", new { letter = "J" })
  17. @Html.ActionLink("K", "Index", new { letter = "K" })
  18. @Html.ActionLink("L", "Index", new { letter = "L" })
  19. @Html.ActionLink("M", "Index", new { letter = "M" })
  20. @Html.ActionLink("N", "Index", new { letter = "N" })
  21. @Html.ActionLink("O", "Index", new { letter = "O" })
  22. @Html.ActionLink("P", "Index", new { letter = "P" })
  23. @Html.ActionLink("Q", "Index", new { letter = "Q" })
  24. @Html.ActionLink("R", "Index", new { letter = "R" })
  25. @Html.ActionLink("S", "Index", new { letter = "S" })
  26. @Html.ActionLink("T", "Index", new { letter = "T" })
  27. @Html.ActionLink("U", "Index", new { letter = "U" })
  28. @Html.ActionLink("V", "Index", new { letter = "V" })
  29. @Html.ActionLink("W", "Index", new { letter = "W" })
  30. @Html.ActionLink("X", "Index", new { letter = "X" })
  31. @Html.ActionLink("Y", "Index", new { letter = "Y" })
  32. @Html.ActionLink("Z", "Index", new { letter = "Z" })
  33. @Html.ActionLink("All", "Index", new { letter = "all" })
  34.  
  35.  
  36. <ul>
  37. @foreach (var artist in Model)
  38. {
  39. <li>@Html.ActionLink(artist.Name,
  40. "Browse", new { id = artist.ArtistId })</li>
  41. }
  42. </ul>
  43.  
  44. public ActionResult Index(string letter = "")
  45. {
  46. IEnumerable<Artist> artist;
  47.  
  48. if (letter == "all")
  49. {
  50. artist = storeDB.Artists.OrderBy(x =>x.Name).ToList();
  51. }
  52. else if (letter != "")
  53. {
  54. artist = storeDB.Artists.Where(a => a.Name.StartsWith(letter)).OrderBy(x => x.Name).ToList();
  55. }
  56. else
  57. {
  58. artist = new List<Artist>();
  59. }
  60.  
  61. @if(Model.Any())
  62. {
  63. foreach (var artist in Model)
  64. {
  65. <li>@Html.ActionLink(artist.Name,
  66. "Browse", new { id = artist.ArtistId })</li>
  67. }
  68. }
  69. else
  70. {
  71. <span>There are no artists</span>
  72. }
Add Comment
Please, Sign In to add comment