Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. @model List<MusicManager.Models.Song>
  2.  
  3. @{
  4. ViewBag.Title = "Music";
  5. }
  6.  
  7. <div id="addButton">
  8. <button type="button" class="btn btn-success btn-lg margin-right"><span class="glyphicon glyphicon-plus"></span>@Html.ActionLink("Add", "Add", "Music", null, new { @class="addButton" })</button>
  9. </div>
  10.  
  11. <h3>@ViewBag.Message</h3>
  12.  
  13. <table class="table">
  14. <tr>
  15. <th>SongId</th>
  16. <th>Song</th>
  17. <th>Artist</th>
  18. <th>Album</th>
  19. <th>Duration</th>
  20. <th>&nbsp;</th>
  21. </tr>
  22. @foreach (var song in Model)
  23. {
  24. <tr>
  25. <td>@song.SongId</td>
  26. <td>@song.SongName</td>
  27. <td>@song.ArtistName</td>
  28. <td>@song.AlbumName</td>
  29. <td>@song.Duration</td>
  30. <td>
  31. <div class="pull-right">
  32. <a href="@Url.Action("Edit", new { id = song.SongId })" class="btn btn-warning btn-sm margin-right">
  33. <span class="glyphicon glyphicon-edit"></span><span class="hidden-xs"> Edit</span>
  34. </a>
  35. <a href="@Url.Action("Delete", new { id = song.SongId })" class="btn btn-danger btn-sm">
  36. <span class="glyphicon glyphicon-trash"></span><span class="hidden-xs"> Delete</span>
  37. </a>
  38. </div>
  39. </td>
  40. </tr>
  41. }
  42. </table>
  43.  
  44. using System;
  45. using System.Collections.Generic;
  46. using System.ComponentModel;
  47. using System.ComponentModel.DataAnnotations;
  48. using System.Linq;
  49. using System.Web;
  50.  
  51. namespace MusicManager.Models
  52. {
  53. public class Song
  54. {
  55. /// <summary>
  56. /// Default constructor
  57. /// </summary>
  58. public Song()
  59. { }
  60.  
  61. /// <summary>
  62. /// The Id of the song.
  63. /// </summary>
  64. public int SongId { get; set; }
  65.  
  66. /// <summary>
  67. /// The name of the song.
  68. /// </summary>
  69. [Required]
  70. [DisplayName("Song")]
  71. public string SongName { get; set; }
  72.  
  73. /// <summary>
  74. /// The artist of the song.
  75. /// </summary>
  76. [Required, StringLength(100)]
  77. [DisplayName("Artist")]
  78. public string ArtistName { get; set; }
  79.  
  80. /// <summary>
  81. /// Represents an album from an artist.
  82. /// </summary>
  83. [Required, StringLength(50)]
  84. [DisplayName("Album")]
  85. public string AlbumName { get; set; }
  86.  
  87. /// <summary>
  88. /// The duration of the song.
  89. /// </summary>
  90. public double Duration { get; set; }
  91.  
  92. /// <summary>
  93. /// Whether or not this song should be excluded when calculating the total duration of the current playlist.
  94. /// </summary>
  95. public bool Exclude { get; set; }
  96. }
  97. }
  98.  
  99. public class MusicController : Controller
  100. {
  101. SongDatabase db = new SongDatabase();
  102.  
  103. // GET: Songs
  104. [HttpGet]
  105. public ActionResult Music()
  106. {
  107. List<Song> songs = db.Songs
  108. .ToList();
  109.  
  110. return View(songs);
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement