/
editAlbum.cshtml
72 lines (63 loc) · 2.32 KB
/
editAlbum.cshtml
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
@using FreyaMusicStore
@{
Layout = "layout";
}
@section Main
{
<h2>Create</h2>
<form>
<fieldset>
<legend>Album</legend>
<div class="editor-label">Genre</div>
<div class="editor-field">
<select name="GenreId">
@foreach (var genre in Model.Genres)
{
<option value="@genre.Id" @(genre.Id == Model.Album.GenreId? "selected" : "") >@genre.Name</option>
}
</select>
</div>
<div class="editor-label">Artist</div>
<div class="editor-field">
<select name="ArtistId">
@foreach (var artist in Model.Artists)
{
<option value="@artist.Id" @(artist.Id == Model.Album.ArtistId? "selected" : "") >@artist.Name</option>
}
</select>
</div>
<div class="editor-label">Title</div>
<div class="editor-field">
<input name="Title" type="text" required="" maxlength="100" value="@Model.Album.Title">
</div>
<div class="editor-label">Price</div>
<div class="editor-field">
<input name="Price" type="number" required="" min="0.01" max="100.0" step="0.01" value="@Model.Album.Price.ToString(System.Globalization.CultureInfo.InvariantCulture)">
</div>
<div class="editor-label">Album Art Url</div>
<div class="editor-field">
<input name="ArtUrl" type="text" required="" value="@Model.Album.AlbumArtUrl" maxlength="100">
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
</form>
<div>
<a href="@Uris.albums">Back to albums</a>
</div>
<script>
$('form').submit(function (event) {
var success = function(data){
window.location = String.format("@Uris.album", @Model.Album.AlbumId);
}
$.ajax({
type: "PUT",
data: $( this ).serializeArray(),
url: String.format("@Uris.album", @Model.Album.AlbumId),
success: success
});
event.preventDefault();
});
</script>
}