public HttpResponseMessage GetAllAlbums() { using (var db = new OnlineMusicEntities()) { var query = dto.GetAlbumQuery(db, null, true); var listAlbums = query.OrderByDescending(a => a.Id).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, listAlbums)); } }
public HttpResponseMessage GetAlbums([FromUri] int id) { using (var db = new OnlineMusicEntities()) { var query = dto.GetArtistQuery(db); var artist = query.Where(a => a.Id == id).FirstOrDefault(); if (artist == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Không tìm thấy nghệ sĩ id=" + id)); } var albumList = albumDto.GetAlbumQuery(db, album => album.ArtistId == id).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, albumList)); } }