Example #1
0
        public static Album ToModel(this AlbumResource resource)
        {
            if (resource == null)
            {
                return(null);
            }

            var artist = resource.Artist?.ToModel() ?? new NzbDrone.Core.Music.Artist();

            return(new Album
            {
                Id = resource.Id,
                ForeignAlbumId = resource.ForeignAlbumId,
                Title = resource.Title,
                Disambiguation = resource.Disambiguation,
                Overview = resource.Overview,
                Images = resource.Images,
                AlbumType = resource.AlbumType,
                Monitored = resource.Monitored,
                AnyReleaseOk = resource.AnyReleaseOk,
                AlbumReleases = resource.Releases.ToModel(),
                AddOptions = resource.AddOptions,
                Artist = artist,
                ArtistMetadata = artist.Metadata.Value
            });
        }
Example #2
0
        public static Album ToModel(this AlbumResource resource, Album album)
        {
            var updatedAlbum = resource.ToModel();

            album.ApplyChanges(updatedAlbum);
            album.AlbumReleases = updatedAlbum.AlbumReleases;

            return(album);
        }
Example #3
0
        private void UpdateAlbum(AlbumResource albumResource)
        {
            var album = _albumService.GetAlbum(albumResource.Id);

            var model = albumResource.ToModel(album);

            _albumService.UpdateAlbum(model);
            _releaseService.UpdateMany(model.AlbumReleases.Value);

            BroadcastResourceChange(ModelAction.Updated, model.Id);
        }
Example #4
0
        public static Album ToModel(this AlbumResource resource)
        {
            if (resource == null)
            {
                return(null);
            }

            return(new Album
            {
                Id = resource.Id,
                ForeignAlbumId = resource.ForeignAlbumId,
                Title = resource.Title,
                Disambiguation = resource.Disambiguation,
                Overview = resource.Overview,
                Images = resource.Images,
                Monitored = resource.Monitored,
                AnyReleaseOk = resource.AnyReleaseOk,
                AlbumReleases = resource.Releases.ToModel()
            });
        }
Example #5
0
        private int AddAlbum(AlbumResource albumResource)
        {
            var album = _addAlbumService.AddAlbum(albumResource.ToModel());

            return(album.Id);
        }