You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
913 B
30 lines
913 B
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Nancy;
|
|
using Nancy.Extensions;
|
|
using NzbDrone.Api.Extensions;
|
|
using NzbDrone.Core.Music;
|
|
|
|
namespace NzbDrone.Api.Music
|
|
{
|
|
public class ListImportModule : NzbDroneApiModule
|
|
{
|
|
private readonly IAddArtistService _artistService;
|
|
|
|
public ListImportModule(IAddArtistService artistService)
|
|
: base("/artist/import")
|
|
{
|
|
_artistService = artistService;
|
|
Put["/"] = Artist => SaveAll();
|
|
}
|
|
|
|
private Response SaveAll()
|
|
{
|
|
var resources = Request.Body.FromJson<List<ArtistResource>>();
|
|
|
|
var Artists = resources.Select(ArtistResource => (ArtistResource.ToModel())).Where(m => m != null).DistinctBy(m => m.ForeignArtistId).ToList();
|
|
|
|
return _artistService.AddArtists(Artists).ToResource().AsResponse(HttpStatusCode.Accepted);
|
|
}
|
|
}
|
|
} |