예제 #1
0
 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));
     }
 }
예제 #2
0
        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));
            }
        }