Shoko.Server/API/v3/Controllers/FileController.cs
/// <summary>
/// Link one or more episodes to the same file.
/// </summary>
/// <param name="fileID">The file id.</param>
/// <param name="body">The body.</param>
/// <returns></returns>
Link one or more episodes to the same file.
Link one or more episodes to the same file .
[HttpPost("{fileID}/Link")]
        public ActionResult LinkSingleEpisodeToFile(int fileID, [FromBody] File.Input.LinkEpisodesBody body)
        {
            var file = RepoFactory.VideoLocal.GetByID(fileID);
            if (file == null) return NotFound();
            if (RemoveXRefsForFile(file))
                return BadRequest($"Cannot remove associations created from AniDB data for file '{file.VideoLocalID}'");
            foreach (var episodeID in body.episodeIDs)
            {
                var episode = RepoFactory.AnimeEpisode.GetByID(episodeID);
                if (episode == null) return BadRequest("Could not find episode entry");
                var command = new CommandRequest_LinkFileManually(fileID, episode.AnimeEpisodeID);
                command.Save();
            }
            return Ok();
        }
[ HttpPost ( " " ) ] public ActionResult LinkSingleEpisodeToFile ( int fileID , [ FromBody ] File . Input . LinkEpisodesBody body ) { var file = RepoFactory . VideoLocal . GetByID ( fileID ) ; if ( file == null ) return NotFound ( ) ; if ( RemoveXRefsForFile ( file ) ) return BadRequest ( $" Cannot remove associations created from AniDB data for file ' { file . VideoLocalID } ' " ) ; foreach ( var episodeID in body . episodeIDs ) { var episode = RepoFactory . AnimeEpisode . GetByID ( episodeID ) ; if ( episode == null ) return BadRequest ( " " ) ; var command = new CommandRequest_LinkFileManually ( fileID , episode . AnimeEpisodeID ) ; command . Save ( ) ; } return Ok ( ) ; }
Link one or more episodes to the same file.
Link one or more episodes to the same file .
None
fileID
int
The file id.
The file id .
File.Input.LinkEpisodesBody
[FromBody]
body
None