2017-09-04 02:20:56 +00:00
|
|
|
using System.Linq;
|
2021-08-04 20:42:40 +00:00
|
|
|
using Lidarr.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2017-09-04 02:20:56 +00:00
|
|
|
using NzbDrone.Core.Music;
|
|
|
|
|
2017-10-31 01:28:29 +00:00
|
|
|
namespace Lidarr.Api.V1.AlbumStudio
|
2017-09-04 02:20:56 +00:00
|
|
|
{
|
2021-08-04 20:42:40 +00:00
|
|
|
[V1ApiController]
|
|
|
|
public class AlbumStudioController : Controller
|
2017-09-04 02:20:56 +00:00
|
|
|
{
|
|
|
|
private readonly IArtistService _artistService;
|
2017-12-02 05:03:12 +00:00
|
|
|
private readonly IAlbumMonitoredService _albumMonitoredService;
|
2017-09-04 02:20:56 +00:00
|
|
|
|
2021-08-04 20:42:40 +00:00
|
|
|
public AlbumStudioController(IArtistService artistService, IAlbumMonitoredService albumMonitoredService)
|
2017-09-04 02:20:56 +00:00
|
|
|
{
|
|
|
|
_artistService = artistService;
|
2017-12-02 05:03:12 +00:00
|
|
|
_albumMonitoredService = albumMonitoredService;
|
2017-09-04 02:20:56 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 20:42:40 +00:00
|
|
|
[HttpPost]
|
|
|
|
public IActionResult UpdateAll([FromBody] AlbumStudioResource request)
|
2017-09-04 02:20:56 +00:00
|
|
|
{
|
|
|
|
var artistToUpdate = _artistService.GetArtists(request.Artist.Select(s => s.Id));
|
|
|
|
|
|
|
|
foreach (var s in request.Artist)
|
|
|
|
{
|
|
|
|
var artist = artistToUpdate.Single(c => c.Id == s.Id);
|
|
|
|
|
|
|
|
if (s.Monitored.HasValue)
|
|
|
|
{
|
|
|
|
artist.Monitored = s.Monitored.Value;
|
|
|
|
}
|
|
|
|
|
2019-06-12 02:28:57 +00:00
|
|
|
if (request.MonitoringOptions != null && request.MonitoringOptions.Monitor == MonitorTypes.None)
|
|
|
|
{
|
|
|
|
artist.Monitored = false;
|
|
|
|
}
|
|
|
|
|
2017-12-02 05:03:12 +00:00
|
|
|
_albumMonitoredService.SetAlbumMonitoredStatus(artist, request.MonitoringOptions);
|
2017-09-04 02:20:56 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 20:42:40 +00:00
|
|
|
return Accepted();
|
2017-09-04 02:20:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|