Bulk actions and nicer behaviour with implicit profiles

This commit is contained in:
Amelia 2025-05-29 22:29:18 +02:00
parent 9b4a4b8a50
commit 483c90904d
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
18 changed files with 481 additions and 113 deletions

View file

@ -49,26 +49,15 @@ public class ReadingProfileController(ILogger<ReadingProfileController> logger,
/// Updates the given reading profile, must belong to the current user
/// </summary>
/// <param name="dto"></param>
/// <param name="seriesCtx">
/// Optionally, from which series the update is called.
/// If set, will delete the implicit reading profile if it exists
/// </param>
/// <returns></returns>
/// <remarks>This does not update connected series, and libraries. Use
/// <see cref="DeleteProfileFromSeries"/>, <see cref="AddProfileToSeries"/>,
/// <see cref="DeleteProfileFromLibrary"/>, <see cref="AddProfileToLibrary"/>
/// <remarks>
/// This does not update connected series, and libraries.
/// Deletes all implicit profiles for series linked to this profile
/// </remarks>
[HttpPost]
public async Task<ActionResult> UpdateReadingProfile([FromBody] UserReadingProfileDto dto, [FromQuery] int? seriesCtx)
public async Task<ActionResult> UpdateReadingProfile([FromBody] UserReadingProfileDto dto)
{
if (seriesCtx.HasValue)
{
await readingProfileService.DeleteImplicitForSeries(User.GetUserId(), seriesCtx.Value);
}
var success = await readingProfileService.UpdateReadingProfile(User.GetUserId(), dto);
if (!success) return BadRequest();
await readingProfileService.UpdateReadingProfile(User.GetUserId(), dto);
return Ok();
}
@ -92,9 +81,7 @@ public class ReadingProfileController(ILogger<ReadingProfileController> logger,
[HttpPost("series")]
public async Task<ActionResult> UpdateReadingProfileForSeries([FromBody] UserReadingProfileDto dto, [FromQuery] int seriesId)
{
var success = await readingProfileService.UpdateImplicitReadingProfile(User.GetUserId(), seriesId, dto);
if (!success) return BadRequest();
await readingProfileService.UpdateImplicitReadingProfile(User.GetUserId(), seriesId, dto);
return Ok();
}
@ -178,4 +165,17 @@ public class ReadingProfileController(ILogger<ReadingProfileController> logger,
return Ok();
}
/// <summary>
/// Assigns the reading profile to all passes series, and deletes their implicit profiles
/// </summary>
/// <param name="profileId"></param>
/// <param name="seriesIds"></param>
/// <returns></returns>
[HttpPost("batch")]
public async Task<IActionResult> BatchAddReadingProfile([FromQuery] int profileId, [FromBody] IList<int> seriesIds)
{
await readingProfileService.BatchAddProfileToSeries(User.GetUserId(), profileId, seriesIds);
return Ok();
}
}