Lidarr/src/Lidarr.Api.V3/Albums/AlbumResource.cs

68 lines
2.2 KiB
C#
Raw Normal View History

2017-09-04 02:20:56 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using NzbDrone.Core.Music;
using Lidarr.Api.V3.Artist;
using Lidarr.Http.REST;
using NzbDrone.Core.MediaCover;
namespace Lidarr.Api.V3.Albums
{
public class AlbumResource : RestResource
{
public string Title { get; set; }
public int ArtistId { get; set; }
2017-09-18 03:20:36 +00:00
public List<string> AlbumLabel { get; set; }
2017-09-24 19:44:25 +00:00
public string ForeignAlbumId { get; set; }
2017-09-04 02:20:56 +00:00
public bool Monitored { get; set; }
public string Path { get; set; }
public int ProfileId { get; set; }
public int Duration { get; set; }
public string AlbumType { get; set; }
public Ratings Ratings { get; set; }
public DateTime? ReleaseDate { get; set; }
public List<string> Genres { get; set; }
public ArtistResource Artist { get; set; }
public List<MediaCover> Images { get; set; }
public AlbumStatisticsResource Statistics { get; set; }
//Hiding this so people don't think its usable (only used to set the initial state)
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool Grabbed { get; set; }
}
public static class EpisodeResourceMapper
{
public static AlbumResource ToResource(this Album model)
{
if (model == null) return null;
return new AlbumResource
{
Id = model.Id,
ArtistId = model.ArtistId,
AlbumLabel = model.Label,
2017-09-24 19:44:25 +00:00
ForeignAlbumId = model.ForeignAlbumId,
2017-09-04 02:20:56 +00:00
Path = model.Path,
ProfileId = model.ProfileId,
Monitored = model.Monitored,
ReleaseDate = model.ReleaseDate,
Genres = model.Genres,
Title = model.Title,
Images = model.Images,
Ratings = model.Ratings,
Duration = model.Duration,
AlbumType = model.AlbumType
};
}
public static List<AlbumResource> ToResource(this IEnumerable<Album> models)
{
if (models == null) return null;
return models.Select(ToResource).ToList();
}
}
}