Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model List<MusicManager.Models.Song>
- @{
- ViewBag.Title = "Music";
- }
- <div id="addButton">
- <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>
- </div>
- <h3>@ViewBag.Message</h3>
- <table class="table">
- <tr>
- <th>SongId</th>
- <th>Song</th>
- <th>Artist</th>
- <th>Album</th>
- <th>Duration</th>
- <th> </th>
- </tr>
- @foreach (var song in Model)
- {
- <tr>
- <td>@song.SongId</td>
- <td>@song.SongName</td>
- <td>@song.ArtistName</td>
- <td>@song.AlbumName</td>
- <td>@song.Duration</td>
- <td>
- <div class="pull-right">
- <a href="@Url.Action("Edit", new { id = song.SongId })" class="btn btn-warning btn-sm margin-right">
- <span class="glyphicon glyphicon-edit"></span><span class="hidden-xs"> Edit</span>
- </a>
- <a href="@Url.Action("Delete", new { id = song.SongId })" class="btn btn-danger btn-sm">
- <span class="glyphicon glyphicon-trash"></span><span class="hidden-xs"> Delete</span>
- </a>
- </div>
- </td>
- </tr>
- }
- </table>
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Web;
- namespace MusicManager.Models
- {
- public class Song
- {
- /// <summary>
- /// Default constructor
- /// </summary>
- public Song()
- { }
- /// <summary>
- /// The Id of the song.
- /// </summary>
- public int SongId { get; set; }
- /// <summary>
- /// The name of the song.
- /// </summary>
- [Required]
- [DisplayName("Song")]
- public string SongName { get; set; }
- /// <summary>
- /// The artist of the song.
- /// </summary>
- [Required, StringLength(100)]
- [DisplayName("Artist")]
- public string ArtistName { get; set; }
- /// <summary>
- /// Represents an album from an artist.
- /// </summary>
- [Required, StringLength(50)]
- [DisplayName("Album")]
- public string AlbumName { get; set; }
- /// <summary>
- /// The duration of the song.
- /// </summary>
- public double Duration { get; set; }
- /// <summary>
- /// Whether or not this song should be excluded when calculating the total duration of the current playlist.
- /// </summary>
- public bool Exclude { get; set; }
- }
- }
- public class MusicController : Controller
- {
- SongDatabase db = new SongDatabase();
- // GET: Songs
- [HttpGet]
- public ActionResult Music()
- {
- List<Song> songs = db.Songs
- .ToList();
- return View(songs);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement