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.
62 lines
1.6 KiB
62 lines
1.6 KiB
6 years ago
|
using System.Collections.Generic;
|
||
5 years ago
|
using Lidarr.Http;
|
||
3 years ago
|
using Lidarr.Http.REST;
|
||
|
using Lidarr.Http.REST.Attributes;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
7 years ago
|
using NzbDrone.Core.Datastore.Events;
|
||
|
using NzbDrone.Core.Messaging.Events;
|
||
|
using NzbDrone.Core.Tags;
|
||
|
using NzbDrone.SignalR;
|
||
|
|
||
7 years ago
|
namespace Lidarr.Api.V1.Tags
|
||
7 years ago
|
{
|
||
3 years ago
|
[V1ApiController]
|
||
|
public class TagController : RestControllerWithSignalR<TagResource, Tag>, IHandle<TagsUpdatedEvent>
|
||
7 years ago
|
{
|
||
|
private readonly ITagService _tagService;
|
||
|
|
||
3 years ago
|
public TagController(IBroadcastSignalRMessage signalRBroadcaster,
|
||
7 years ago
|
ITagService tagService)
|
||
|
: base(signalRBroadcaster)
|
||
|
{
|
||
|
_tagService = tagService;
|
||
|
}
|
||
|
|
||
3 years ago
|
public override TagResource GetResourceById(int id)
|
||
7 years ago
|
{
|
||
|
return _tagService.GetTag(id).ToResource();
|
||
|
}
|
||
|
|
||
3 years ago
|
[HttpGet]
|
||
|
public List<TagResource> GetAll()
|
||
7 years ago
|
{
|
||
|
return _tagService.All().ToResource();
|
||
|
}
|
||
|
|
||
3 years ago
|
[RestPostById]
|
||
|
public ActionResult<TagResource> Create(TagResource resource)
|
||
7 years ago
|
{
|
||
3 years ago
|
return Created(_tagService.Add(resource.ToModel()).Id);
|
||
7 years ago
|
}
|
||
|
|
||
3 years ago
|
[RestPutById]
|
||
|
public ActionResult<TagResource> Update(TagResource resource)
|
||
7 years ago
|
{
|
||
|
_tagService.Update(resource.ToModel());
|
||
3 years ago
|
return Accepted(resource.Id);
|
||
7 years ago
|
}
|
||
|
|
||
3 years ago
|
[RestDeleteById]
|
||
|
public void DeleteTag(int id)
|
||
7 years ago
|
{
|
||
|
_tagService.Delete(id);
|
||
|
}
|
||
|
|
||
3 years ago
|
[NonAction]
|
||
7 years ago
|
public void Handle(TagsUpdatedEvent message)
|
||
|
{
|
||
|
BroadcastResourceChange(ModelAction.Sync);
|
||
|
}
|
||
|
}
|
||
|
}
|