@@ -51,19 +51,17 @@ public AlbumViewerApiController(
51
51
HostingEnv = env ;
52
52
}
53
53
54
-
55
54
56
-
57
- [ HttpGet ]
58
- [ Route ( "api/throw" ) ]
59
- public object Throw ( )
60
- {
61
- throw new InvalidOperationException ( "This is an unhandled exception" ) ;
62
- }
63
-
64
-
65
55
#region albums
66
56
57
+ /// <summary>
58
+ /// A list of albums with detail artist data
59
+ /// </summary>
60
+ /// <param name="page"></param>
61
+ /// <param name="pageSize"></param>
62
+ /// <returns></returns>
63
+ /// <response code="200">Album List</response>
64
+ /// <response code="500">Failed to retrieve albums</response>
67
65
[ HttpGet ]
68
66
[ Route ( "api/albums" ) ]
69
67
public async Task < IEnumerable < Album > > GetAlbums ( int page = - 1 , int pageSize = 15 )
@@ -72,12 +70,23 @@ public async Task<IEnumerable<Album>> GetAlbums(int page = -1, int pageSize = 15
72
70
return await AlbumRepo . GetAllAlbums ( page , pageSize ) ;
73
71
}
74
72
73
+ /// <summary>
74
+ /// Returns an individual album
75
+ /// </summary>
76
+ /// <param name="id"></param>
77
+ /// <returns></returns>
75
78
[ HttpGet ( "api/album/{id:int}" ) ]
76
79
public async Task < Album > GetAlbum ( int id )
77
80
{
78
81
return await AlbumRepo . Load ( id ) ;
79
82
}
80
83
84
+ /// <summary>
85
+ /// Update or add a new album
86
+ /// </summary>
87
+ /// <param name="postedAlbum"></param>
88
+ /// <returns></returns>
89
+ /// <exception cref="ApiException"></exception>
81
90
[ HttpPost ( "api/album" ) ]
82
91
public async Task < Album > SaveAlbum ( [ FromBody ] Album postedAlbum )
83
92
{
@@ -103,6 +112,13 @@ public async Task<Album> SaveAlbum([FromBody] Album postedAlbum)
103
112
return album ;
104
113
}
105
114
115
+
116
+ /// <summary>
117
+ /// Delete a specific album by id
118
+ /// </summary>
119
+ /// <param name="id"></param>
120
+ /// <returns></returns>
121
+ /// <exception cref="ApiException"></exception>
106
122
[ HttpDelete ( "api/album/{id:int}" ) ]
107
123
public async Task < bool > DeleteAlbum ( int id )
108
124
{
@@ -113,6 +129,12 @@ public async Task<bool> DeleteAlbum(int id)
113
129
}
114
130
115
131
132
+ /// <summary>
133
+ /// Delete an album by its album name
134
+ /// </summary>
135
+ /// <param name="name"></param>
136
+ /// <returns></returns>
137
+ /// <exception cref="ApiException"></exception>
116
138
[ HttpGet ]
117
139
public async Task < string > DeleteAlbumByName ( string name )
118
140
{
@@ -139,13 +161,23 @@ await context.Albums
139
161
140
162
#region artists
141
163
164
+ /// <summary>
165
+ /// Return a list of Artists
166
+ /// </summary>
167
+ /// <returns></returns>
142
168
[ HttpGet ]
143
169
[ Route ( "api/artists" ) ]
144
170
public async Task < IEnumerable > GetArtists ( )
145
171
{
146
172
return await ArtistRepo . GetAllArtists ( ) ;
147
173
}
148
174
175
+ /// <summary>
176
+ /// Return an individual Artist
177
+ /// </summary>
178
+ /// <param name="id"></param>
179
+ /// <returns></returns>
180
+ /// <exception cref="ApiException"></exception>
149
181
[ HttpGet ( "api/artist/{id:int}" ) ]
150
182
public async Task < object > Artist ( int id )
151
183
{
@@ -163,6 +195,12 @@ public async Task<object> Artist(int id)
163
195
} ;
164
196
}
165
197
198
+ /// <summary>
199
+ /// Update or add a new Artist
200
+ /// </summary>
201
+ /// <param name="artist"></param>
202
+ /// <returns></returns>
203
+ /// <exception cref="ApiException"></exception>
166
204
[ HttpPost ( "api/artist" ) ]
167
205
public async Task < ArtistResponse > SaveArtist ( [ FromBody ] Artist artist )
168
206
{
@@ -187,6 +225,11 @@ public async Task<ArtistResponse> SaveArtist([FromBody] Artist artist)
187
225
} ;
188
226
}
189
227
228
+ /// <summary>
229
+ /// Look up an artist by name (search functionality)
230
+ /// </summary>
231
+ /// <param name="search"></param>
232
+ /// <returns></returns>
190
233
[ HttpGet ( "api/artistlookup" ) ]
191
234
public async Task < IEnumerable < object > > ArtistLookup ( string search = null )
192
235
{
@@ -199,6 +242,12 @@ public async Task<IEnumerable<object>> ArtistLookup(string search = null)
199
242
}
200
243
201
244
245
+ /// <summary>
246
+ /// Delete an individual artist by Id
247
+ /// </summary>
248
+ /// <param name="id"></param>
249
+ /// <returns></returns>
250
+ /// <exception cref="ApiException"></exception>
202
251
[ HttpDelete ( "api/artist/{id:int}" ) ]
203
252
public async Task < bool > DeleteArtist ( int id )
204
253
{
@@ -210,6 +259,20 @@ public async Task<bool> DeleteArtist(int id)
210
259
211
260
#endregion
212
261
262
+ /// <summary>
263
+ /// Sample endpoint that explicitly raises an exception to
264
+ /// demonstrate default error results.
265
+ /// </summary>
266
+ /// <returns></returns>
267
+ /// <exception cref="InvalidOperationException"></exception>
268
+ /// <response code="500">Unhandled exception thrown - error response</response>
269
+ [ HttpGet ]
270
+ [ Route ( "api/throw" ) ]
271
+ public object Throw ( )
272
+ {
273
+ throw new InvalidOperationException ( "This is an unhandled exception" ) ;
274
+ }
275
+
213
276
#region admin
214
277
[ HttpGet ]
215
278
[ Route ( "api/reloaddata" ) ]
0 commit comments