mirror of
https://github.com/C9Glax/tranga.git
synced 2025-10-11 05:09:49 +02:00
Add Controller
This commit is contained in:
22
API/Controllers/Requests/PatchLibraryRefreshRecord.cs
Normal file
22
API/Controllers/Requests/PatchLibraryRefreshRecord.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using API.Workers;
|
||||
|
||||
namespace API.Controllers.Requests;
|
||||
|
||||
public record PatchLibraryRefreshRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// When to refresh the Library
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Description("When to refresh the Library")]
|
||||
public required LibraryRefreshSetting Setting { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// When <see cref="LibraryRefreshSetting.WhileDownloading"/> is selected, update the time between refreshes
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Description("When WhileDownloadingis selected, update the time between refreshes")]
|
||||
public required int? RefreshLibraryWhileDownloadingEveryMinutes { get; init; }
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
using API.MangaDownloadClients;
|
||||
using API.Controllers.Requests;
|
||||
using API.MangaDownloadClients;
|
||||
using Asp.Versioning;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -290,4 +291,19 @@ public class SettingsController() : Controller
|
||||
Tranga.Settings.SetDownloadLanguage(Language);
|
||||
return TypedResults.Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the time when Libraries are refreshed
|
||||
/// </summary>
|
||||
/// <response code="200"></response>
|
||||
[HttpPatch("LibraryRefresh")]
|
||||
[ProducesResponseType(Status200OK)]
|
||||
public Ok SetLibraryRefresh([FromBody]PatchLibraryRefreshRecord requestData)
|
||||
{
|
||||
Tranga.Settings.SetLibraryRefreshSetting(requestData.Setting);
|
||||
if(requestData.RefreshLibraryWhileDownloadingEveryMinutes is { } value)
|
||||
Tranga.Settings.SetRefreshLibraryWhileDownloadingEveryMinutes(value);
|
||||
return TypedResults.Ok();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user