Esempio n. 1
0
        public static List <GenreJson> From(List <Genre> genres)
        {
            List <GenreJson> results = new List <GenreJson>();

            if (genres == null)
            {
                return(results);
            }

            foreach (Genre g in genres)
            {
                results.Add(GenreJson.From(g));
            }
            return(results);
        }
Esempio n. 2
0
        public static GenreJson From(Genre genre)
        {
            var result = new GenreJson()
            {
                GenreId     = genre.GenreId,
                Name        = genre.Name,
                Description = genre.Description,
                AlbumIds    = new List <int>()
            };

            foreach (Album a in genre.Albums)
            {
                result.AlbumIds.Add(a.AlbumId);
            }
            return(result);
        }
Esempio n. 3
0
        public static AlbumJson From(Album album)
        {
            var result = new AlbumJson()
            {
                AlbumId     = album.AlbumId,
                GenreId     = album.GenreId,
                ArtistId    = album.ArtistId,
                Title       = album.Title,
                Price       = album.Price,
                AlbumArtUrl = album.AlbumArtUrl,
                Created     = album.Created,
                OrderCount  = album.OrderCount,
                Artist      = ArtistJson.From(album.Artist),
                Genre       = GenreJson.From(album.Genre)
            };

            return(result);
        }
Esempio n. 4
0
 public static Genre From(GenreJson genre)
 {
     if (genre != null)
     {
         return(new Genre()
         {
             GenreId = genre.GenreId,
             Name = genre.Name,
             Description = genre.Description,
             Albums = new List <Album>()
         });
     }
     else
     {
         return(new Genre()
         {
             GenreId = 0,
             Name = "Not Found",
             Description = "Not Found",
             Albums = new List <Album>()
         });
     }
 }