mirror of
https://github.com/Lidarr/Lidarr
synced 2025-12-06 00:16:41 +01:00
Parameter binding for API requests
(cherry picked from commit 074b293d62b56bf02d82ac12ad726777b5d1e478)
This commit is contained in:
parent
1a4c1b6db5
commit
826b8b5933
21 changed files with 34 additions and 34 deletions
|
|
@ -142,7 +142,7 @@ public List<AlbumResource> GetAlbums([FromQuery]int? artistId,
|
|||
}
|
||||
|
||||
[RestPostById]
|
||||
public ActionResult<AlbumResource> AddAlbum(AlbumResource albumResource)
|
||||
public ActionResult<AlbumResource> AddAlbum([FromBody] AlbumResource albumResource)
|
||||
{
|
||||
var album = _addAlbumService.AddAlbum(albumResource.ToModel());
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ public ActionResult<AlbumResource> AddAlbum(AlbumResource albumResource)
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<AlbumResource> UpdateAlbum(AlbumResource albumResource)
|
||||
public ActionResult<AlbumResource> UpdateAlbum([FromBody] AlbumResource albumResource)
|
||||
{
|
||||
var album = _albumService.GetAlbum(albumResource.Id);
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ public void DeleteAlbum(int id, bool deleteFiles = false, bool addImportListExcl
|
|||
}
|
||||
|
||||
[HttpPut("monitor")]
|
||||
public IActionResult SetAlbumsMonitored([FromBody]AlbumsMonitoredResource resource)
|
||||
public IActionResult SetAlbumsMonitored([FromBody] AlbumsMonitoredResource resource)
|
||||
{
|
||||
_albumService.SetMonitored(resource.AlbumIds, resource.Monitored);
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ public List<ArtistResource> AllArtists(Guid? mbId)
|
|||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
public ActionResult<ArtistResource> AddArtist(ArtistResource artistResource)
|
||||
public ActionResult<ArtistResource> AddArtist([FromBody] ArtistResource artistResource)
|
||||
{
|
||||
var artist = _addArtistService.AddArtist(artistResource.ToModel());
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ public ActionResult<ArtistResource> AddArtist(ArtistResource artistResource)
|
|||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
public ActionResult<ArtistResource> UpdateArtist(ArtistResource artistResource, bool moveFiles = false)
|
||||
public ActionResult<ArtistResource> UpdateArtist([FromBody] ArtistResource artistResource, bool moveFiles = false)
|
||||
{
|
||||
var artist = _artistService.GetArtist(artistResource.Id);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public override AutoTaggingResource GetResourceById(int id)
|
|||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<AutoTaggingResource> Create(AutoTaggingResource autoTagResource)
|
||||
public ActionResult<AutoTaggingResource> Create([FromBody] AutoTaggingResource autoTagResource)
|
||||
{
|
||||
var model = autoTagResource.ToModel(_specifications);
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ public ActionResult<AutoTaggingResource> Create(AutoTaggingResource autoTagResou
|
|||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<AutoTaggingResource> Update(AutoTaggingResource resource)
|
||||
public ActionResult<AutoTaggingResource> Update([FromBody] AutoTaggingResource resource)
|
||||
{
|
||||
var model = resource.ToModel(_specifications);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public override CommandResource GetResourceById(int id)
|
|||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
public ActionResult<CommandResource> StartCommand(CommandResource commandResource)
|
||||
public ActionResult<CommandResource> StartCommand([FromBody] CommandResource commandResource)
|
||||
{
|
||||
var commandType =
|
||||
_knownTypes.GetImplementations(typeof(Command))
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public TResource GetConfig()
|
|||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public virtual ActionResult<TResource> SaveConfig(TResource resource)
|
||||
public virtual ActionResult<TResource> SaveConfig([FromBody] TResource resource)
|
||||
{
|
||||
var dictionary = resource.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public HostConfigResource GetHostConfig()
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<HostConfigResource> SaveHostConfig(HostConfigResource resource)
|
||||
public ActionResult<HostConfigResource> SaveHostConfig([FromBody] HostConfigResource resource)
|
||||
{
|
||||
var dictionary = resource.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public NamingConfigResource GetNamingConfig()
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<NamingConfigResource> UpdateNamingConfig(NamingConfigResource resource)
|
||||
public ActionResult<NamingConfigResource> UpdateNamingConfig([FromBody] NamingConfigResource resource)
|
||||
{
|
||||
var nameSpec = resource.ToModel();
|
||||
ValidateFormatResult(nameSpec);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public UiConfigController(IConfigFileProvider configFileProvider, IConfigService
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public override ActionResult<UiConfigResource> SaveConfig(UiConfigResource resource)
|
||||
public override ActionResult<UiConfigResource> SaveConfig([FromBody] UiConfigResource resource)
|
||||
{
|
||||
var dictionary = resource.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public List<CustomFilterResource> GetCustomFilters()
|
|||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<CustomFilterResource> AddCustomFilter(CustomFilterResource resource)
|
||||
public ActionResult<CustomFilterResource> AddCustomFilter([FromBody] CustomFilterResource resource)
|
||||
{
|
||||
var customFilter = _customFilterService.Add(resource.ToModel());
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public ActionResult<CustomFilterResource> AddCustomFilter(CustomFilterResource r
|
|||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<CustomFilterResource> UpdateCustomFilter(CustomFilterResource resource)
|
||||
public ActionResult<CustomFilterResource> UpdateCustomFilter([FromBody] CustomFilterResource resource)
|
||||
{
|
||||
_customFilterService.Update(resource.ToModel());
|
||||
return Accepted(resource.Id);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public List<CustomFormatResource> GetAll()
|
|||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<CustomFormatResource> Create(CustomFormatResource customFormatResource)
|
||||
public ActionResult<CustomFormatResource> Create([FromBody] CustomFormatResource customFormatResource)
|
||||
{
|
||||
var model = customFormatResource.ToModel(_specifications);
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public ActionResult<CustomFormatResource> Create(CustomFormatResource customForm
|
|||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<CustomFormatResource> Update(CustomFormatResource resource)
|
||||
public ActionResult<CustomFormatResource> Update([FromBody] CustomFormatResource resource)
|
||||
{
|
||||
var model = resource.ToModel(_specifications);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public List<ImportListExclusionResource> GetImportListExclusions()
|
|||
}
|
||||
|
||||
[RestPostById]
|
||||
public ActionResult<ImportListExclusionResource> AddImportListExclusion(ImportListExclusionResource resource)
|
||||
public ActionResult<ImportListExclusionResource> AddImportListExclusion([FromBody] ImportListExclusionResource resource)
|
||||
{
|
||||
var customFilter = _importListExclusionService.Add(resource.ToModel());
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ public ActionResult<ImportListExclusionResource> AddImportListExclusion(ImportLi
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<ImportListExclusionResource> UpdateImportListExclusion(ImportListExclusionResource resource)
|
||||
public ActionResult<ImportListExclusionResource> UpdateImportListExclusion([FromBody] ImportListExclusionResource resource)
|
||||
{
|
||||
_importListExclusionService.Update(resource.ToModel());
|
||||
return Accepted(resource.Id);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public ReleaseController(IAlbumService albumService,
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ReleaseResource>> DownloadRelease(ReleaseResource release)
|
||||
public async Task<ActionResult<ReleaseResource>> DownloadRelease([FromBody] ReleaseResource release)
|
||||
{
|
||||
ValidateResource(release);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public ReleasePushController(IMakeDownloadDecision downloadDecisionMaker,
|
|||
|
||||
[HttpPost]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<ReleaseResource> Create(ReleaseResource release)
|
||||
public ActionResult<ReleaseResource> Create([FromBody] ReleaseResource release)
|
||||
{
|
||||
_logger.Info("Release pushed: {0} - {1}", release.Title, release.DownloadUrl ?? release.MagnetUrl);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public ManualImportController(IManualImportService manualImportService,
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult UpdateItems(List<ManualImportUpdateResource> resource)
|
||||
public IActionResult UpdateItems([FromBody] List<ManualImportUpdateResource> resource)
|
||||
{
|
||||
return Accepted(UpdateImportItems(resource));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public DelayProfileController(IDelayProfileService delayProfileService, DelayPro
|
|||
}
|
||||
|
||||
[RestPostById]
|
||||
public ActionResult<DelayProfileResource> Create(DelayProfileResource resource)
|
||||
public ActionResult<DelayProfileResource> Create([FromBody] DelayProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
model = _delayProfileService.Add(model);
|
||||
|
|
@ -54,7 +54,7 @@ public void DeleteProfile(int id)
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<DelayProfileResource> Update(DelayProfileResource resource)
|
||||
public ActionResult<DelayProfileResource> Update([FromBody] DelayProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
_delayProfileService.Update(model);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public MetadataProfileController(IMetadataProfileService profileService)
|
|||
}
|
||||
|
||||
[RestPostById]
|
||||
public ActionResult<MetadataProfileResource> Create(MetadataProfileResource resource)
|
||||
public ActionResult<MetadataProfileResource> Create([FromBody] MetadataProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
model = _profileService.Add(model);
|
||||
|
|
@ -38,7 +38,7 @@ public void DeleteProfile(int id)
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<MetadataProfileResource> Update(MetadataProfileResource resource)
|
||||
public ActionResult<MetadataProfileResource> Update([FromBody] MetadataProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public QualityProfileController(IQualityProfileService qualityProfileService, IC
|
|||
}
|
||||
|
||||
[RestPostById]
|
||||
public ActionResult<QualityProfileResource> Create(QualityProfileResource resource)
|
||||
public ActionResult<QualityProfileResource> Create([FromBody] QualityProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
model = _qualityProfileService.Add(model);
|
||||
|
|
@ -58,7 +58,7 @@ public void DeleteProfile(int id)
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<QualityProfileResource> Update(QualityProfileResource resource)
|
||||
public ActionResult<QualityProfileResource> Update([FromBody] QualityProfileResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
|
||||
|
|
|
|||
|
|
@ -47,13 +47,13 @@ public List<ReleaseProfileResource> GetAll()
|
|||
}
|
||||
|
||||
[RestPostById]
|
||||
public ActionResult<ReleaseProfileResource> Create(ReleaseProfileResource resource)
|
||||
public ActionResult<ReleaseProfileResource> Create([FromBody] ReleaseProfileResource resource)
|
||||
{
|
||||
return Created(_releaseProfileService.Add(resource.ToModel()).Id);
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<ReleaseProfileResource> Update(ReleaseProfileResource resource)
|
||||
public ActionResult<ReleaseProfileResource> Update([FromBody] ReleaseProfileResource resource)
|
||||
{
|
||||
_releaseProfileService.Update(resource.ToModel());
|
||||
return Accepted(resource.Id);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public QualityDefinitionController(IQualityDefinitionService qualityDefinitionSe
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<QualityDefinitionResource> Update(QualityDefinitionResource resource)
|
||||
public ActionResult<QualityDefinitionResource> Update([FromBody] QualityDefinitionResource resource)
|
||||
{
|
||||
var model = resource.ToModel();
|
||||
_qualityDefinitionService.Update(model);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public override RootFolderResource GetResourceById(int id)
|
|||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<RootFolderResource> CreateRootFolder(RootFolderResource rootFolderResource)
|
||||
public ActionResult<RootFolderResource> CreateRootFolder([FromBody] RootFolderResource rootFolderResource)
|
||||
{
|
||||
var model = rootFolderResource.ToModel();
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ public ActionResult<RootFolderResource> CreateRootFolder(RootFolderResource root
|
|||
}
|
||||
|
||||
[RestPutById]
|
||||
public ActionResult<RootFolderResource> UpdateRootFolder(RootFolderResource rootFolderResource)
|
||||
public ActionResult<RootFolderResource> UpdateRootFolder([FromBody] RootFolderResource rootFolderResource)
|
||||
{
|
||||
var model = rootFolderResource.ToModel();
|
||||
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ public List<TagResource> GetAll()
|
|||
|
||||
[RestPostById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<TagResource> Create(TagResource resource)
|
||||
public ActionResult<TagResource> Create([FromBody] TagResource resource)
|
||||
{
|
||||
return Created(_tagService.Add(resource.ToModel()).Id);
|
||||
}
|
||||
|
||||
[RestPutById]
|
||||
[Consumes("application/json")]
|
||||
public ActionResult<TagResource> Update(TagResource resource)
|
||||
public ActionResult<TagResource> Update([FromBody] TagResource resource)
|
||||
{
|
||||
_tagService.Update(resource.ToModel());
|
||||
return Accepted(resource.Id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue