@model IEnumerable<MusicStore.Models.Album>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Genre.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().Artist.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().Title)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstOrDefault().Price)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Genre.Name)
            </td>
            <td>
                @if (item.Artist.Name.Length <= 25)
                {
                    @item.Artist.Name
                }
                else
                {
                    @item.Artist.Name.Substring(0, 25)<text>...</text>
                }
            </td>
            <td>
                @if (item.Title.Length <= 25)
                {
                    @item.Title
                }
                else
                {
                    @item.Title.Substring(0, 25)<text>...</text>
                }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Price)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.AlbumId }) |
                @Html.ActionLink("Details", "Details", new { id = item.AlbumId }) |
                @Html.ActionLink("Delete", "RemoveAlbum", new { id = item.AlbumId })
            </td>
        </tr>
    }

</table>