-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathalbums.cshtml
More file actions
81 lines (77 loc) · 1.65 KB
/
albums.cshtml
File metadata and controls
81 lines (77 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@using FreyaMusicStore
@{
Layout = "layout";
}
@helper Truncate(string input, int length)
{
if (input.Length <= length)
{
@input
}
else
{
@input.Substring(0, length)<text>...</text>
}
}
@section Main
{
<h2>Index</h2>
<p>
<a href="@Uris.newAlbum">Create New</a>
</p>
<table>
<tr>
<th>
Title
</th>
<th>
Genre
</th>
<th>
Artist
</th>
<th>
Price
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
<a href="@String.Format(Uris.album, item.AlbumId)">@Truncate(item.Title, 25)</a>
</td>
<td>
@item.Genre
</td>
<td>
@Truncate(item.Artist, 25)
</td>
<td>
@item.Price
</td>
<td>
<a href="#" class="delete" data-id="@item.AlbumId">Delete</a> |
<a href="@String.Format(Uris.editAlbum, item.AlbumId)">Edit</a>
</td>
</tr>
}
</table>
<script type="text/javascript">
$('.delete').click(function (a) {
var id = Number.parseInt($(a.target).attr("data-id"))
var confirmation = confirm("delete album with id" + id + " ?");
var success = function () {
$(a.target).closest('tr').fadeOut();
}
if (confirmation){
$.ajax({
type: "DELETE",
url: String.format("@Uris.album", id),
success: success
});
}
return false;
});
</script>
}