Lidarr/src/Lidarr.Api.V1/AlbumStudio/AlbumStudioController.cs

51 lines
1.6 KiB
C#
Raw Normal View History

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;
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;
_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;
}
if (request.MonitoringOptions != null && request.MonitoringOptions.Monitor == MonitorTypes.None)
{
artist.Monitored = false;
}
if (request.MonitorNewItems.HasValue)
{
artist.MonitorNewItems = request.MonitorNewItems.Value;
}
_albumMonitoredService.SetAlbumMonitoredStatus(artist, request.MonitoringOptions);
2017-09-04 02:20:56 +00:00
}
return Accepted(request);
2017-09-04 02:20:56 +00:00
}
}
}