Lidarr/src/Lidarr.Api.V1/Artist/ArtistImportModule.cs

29 lines
771 B
C#
Raw Normal View History

2017-09-04 02:20:56 +00:00
using System.Collections.Generic;
using Lidarr.Http;
using Lidarr.Http.Extensions;
using Nancy;
using NzbDrone.Core.Music;
2017-09-04 02:20:56 +00:00
2017-10-31 01:28:29 +00:00
namespace Lidarr.Api.V1.Artist
2017-09-04 02:20:56 +00:00
{
public class ArtistImportModule : LidarrRestModule<ArtistResource>
{
private readonly IAddArtistService _addArtistService;
public ArtistImportModule(IAddArtistService addArtistService)
: base("/artist/import")
{
_addArtistService = addArtistService;
Post("/", x => Import());
2017-09-04 02:20:56 +00:00
}
2019-09-12 20:32:51 +00:00
private object Import()
2017-09-04 02:20:56 +00:00
{
var resource = Request.Body.FromJson<List<ArtistResource>>();
var newArtists = resource.ToModel();
2017-09-04 02:20:56 +00:00
2019-09-12 20:32:51 +00:00
return _addArtistService.AddArtists(newArtists).ToResource();
2017-09-04 02:20:56 +00:00
}
}
}